Jesus Carrasco commited on
Commit
c3223e2
·
1 Parent(s): e61b92f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -1,19 +1,30 @@
1
  import openai
2
  import gradio as gr
 
3
 
4
- # Your chatbot function here
5
- def chatbot(input_text):
6
- # Code to interact with GPT-3.5 Turbo and get a response
7
- # ...
 
 
 
 
 
 
 
 
 
 
8
  return response
9
 
10
- # Create a Gradio UI for the chatbot function
11
  iface = gr.Interface(
12
  fn=chatbot,
13
- inputs=gr.inputs.Textbox(lines=5, label="Your input"),
14
- outputs=gr.outputs.Textbox(label="Chatbot response"),
15
- title="Chatbot using GPT-3.5 Turbo",
 
16
  )
17
 
18
- # Start the Gradio server
19
  iface.launch()
 
 
1
  import openai
2
  import gradio as gr
3
+ from openai.api_resources import engines
4
 
5
+ openai.api_key = "your-api-key"
6
+
7
+ model_engine = "gpt-3.5-turbo"
8
+
9
+ def chatbot(prompt):
10
+ completions = openai.Completion.create(
11
+ engine=model_engine,
12
+ prompt=prompt,
13
+ max_tokens=100,
14
+ n=1,
15
+ stop=None,
16
+ temperature=0.5,
17
+ )
18
+ response = completions.choices[0].text.strip()
19
  return response
20
 
 
21
  iface = gr.Interface(
22
  fn=chatbot,
23
+ inputs=gr.inputs.Textbox(lines=5, placeholder="Enter your message here..."),
24
+ outputs="text",
25
+ title="Chatbot",
26
+ description="A chatbot using OpenAI's GPT-3.5-turbo",
27
  )
28
 
 
29
  iface.launch()
30
+