Spaces:
Runtime error
Runtime error
| import openai | |
| import gradio as gr | |
| openai.api_key = "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" | |
| messages = [ | |
| {"role": "system", "content": "You are a learning assistant specialized in business information systems."}, | |
| ] | |
| def chatbot(input): | |
| if input: | |
| messages.append({"role": "user", "content": input}) | |
| chat = openai.chat.completions.create( | |
| model="gpt-3.5-turbo", messages=messages | |
| ) | |
| reply = chat.choices[0].message.content | |
| messages.append({"role": "assistant", "content": reply}) | |
| return reply | |
| inputs = gr.inputs.Textbox(lines=7, label="Ask questions related to the course.") | |
| outputs = gr.outputs.Textbox(label="Reply") | |
| gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Virtual TA", | |
| description="This is a prototype of learning assistant designed for MIS 320 online section.", | |
| theme="compact").launch(share=True) | |