Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,26 @@
|
|
1 |
-
import openai
|
2 |
-
import gradio as gr
|
3 |
import os
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
model="text-davinci-003", # Specify a non-chat model
|
10 |
-
prompt=prompt,
|
11 |
temperature=0,
|
12 |
max_tokens=750,
|
13 |
top_p=1,
|
14 |
frequency_penalty=0.0,
|
15 |
-
presence_penalty=0.0
|
|
|
16 |
)
|
17 |
-
return response
|
18 |
|
19 |
-
# Gradio interface function
|
20 |
def greet(prompt):
|
21 |
-
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text", title="SQL Generator")
|
25 |
iface.launch()
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
from openai import OpenAI
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
client = OpenAI(api_key=os.environ["SECRET"])
|
6 |
|
7 |
+
def gpt3(texts):
|
8 |
+
response = client.chat.completions.create(
|
9 |
+
model="gpt-4-turbo-preview",
|
10 |
+
messages=[{"role": "user", "content": texts}],
|
|
|
|
|
11 |
temperature=0,
|
12 |
max_tokens=750,
|
13 |
top_p=1,
|
14 |
frequency_penalty=0.0,
|
15 |
+
presence_penalty=0.0,
|
16 |
+
stop=[";", "*/", "</code>"]
|
17 |
)
|
18 |
+
return response.choices[0].message.content
|
19 |
|
|
|
20 |
def greet(prompt):
|
21 |
+
txt = f'''/*Prompt: {prompt}*/ \n'''
|
22 |
+
sql = gpt3(txt)
|
23 |
+
return sql
|
24 |
|
25 |
+
iface = gr.Interface(greet, inputs=["text"], outputs="text")
|
|
|
26 |
iface.launch()
|