Spaces:
Running on CPU Upgrade

File size: 935 Bytes
26211f3
 
1f1ef9d
26211f3
1f1ef9d
26211f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cc7076
26211f3
5cc7076
 
 
1f1ef9d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import openai
import gradio as gr
import os

openai.api_key = os.getenv("OPENAI_API_KEY")

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")

iface = 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")

iface.launch(inline=True)