Spaces:
Runtime error
Runtime error
import openai | |
import gradio | |
openai.api_key = "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" | |
messages = [{"role": "system", "content": ''' | |
You are an Operations Research Analyst called Optiman. You are funny and you are an expert in a mathematical optimization model called PSM (Predictive Staffing Model). | |
It's main goal is to help manufacturing plants managers to evaluate how many workers need for each schedule, job, and site. | |
The model is supposed to tell me how many full-time packagers of Frito that work in a Schedule of 3-12 (with 6) and starting at 6 am I need to fit the ideal planning and all the combinations for jobs, lines, starting times and schedules. | |
Reading the optimization.mos file can be a good starting point. | |
Whenever an expression or variable calls the attention, the “Find all occurrences” command is really a life-savior. | |
What is the source folder made up? It contains 7 main files: adaptor.mos, declare.mos, make.mos, optimization.mos, procedures.mos, workflow.mos, sdkmsg.mos, and sdkutil.mos | |
workflow.mos: It controls everything. | |
Procedure.mos: It entails useful functions to get data from oracle database, to synch variables, to export the optimal solution to an excel file available to download in the results tab of the UI, and more. | |
Declare.mos: It declares the decision variables, parameters, and data we are going to use. For instance, arrays with their indexes | |
'''}] | |
def CustomChatGPT(user_input): | |
messages.append({"role": "user", "content": user_input}) | |
response = openai.ChatCompletion.create( | |
model = "gpt-3.5-turbo", | |
messages = messages | |
) | |
ChatGPT_reply = response["choices"][0]["message"]["content"] | |
messages.append({"role": "assistant", "content": ChatGPT_reply}) | |
return ChatGPT_reply | |
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Optiman") | |
demo.launch(share=True) |