Fiacre commited on
Commit
6a4040c
1 Parent(s): 28b04ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,7 +1,19 @@
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
+ import openai
2
+ import os
3
+
4
+ from dotenv import load_dotenv, find_dotenv
5
+ _ = load_dotenv(find_dotenv()
6
+
7
  import gradio as gr
8
 
9
+ def get_completion(prompt, model="gpt-3.5-turbo"):
10
+ messages = [{"role": "user", "content": prompt}]
11
+ response = openai.ChatCompletion.create(
12
+ model=model,
13
+ messages=messages,
14
+ temperature=0, # this is the degree of randomness of the model's output
15
+ )
16
+ return response.choices[0].message["content"]
17
 
18
+ iface = gr.Interface(fn=get_completion, inputs="text", outputs="text")
19
  iface.launch()