Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,8 @@
|
|
1 |
import openai
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
import gradio as gr
|
7 |
-
|
8 |
-
|
9 |
import os
|
10 |
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
#OpenAi call
|
18 |
|
19 |
|
@@ -21,82 +10,28 @@ def gpt3(texts):
|
|
21 |
|
22 |
|
23 |
openai.api_key = os.environ["Secret"]
|
24 |
-
|
25 |
-
|
26 |
response = openai.Completion.create(
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
top_p=1,
|
42 |
-
|
43 |
-
|
44 |
-
frequency_penalty=0.0,
|
45 |
-
|
46 |
-
|
47 |
-
presence_penalty=0.0,
|
48 |
-
|
49 |
-
|
50 |
-
stop = (";", "/*", "</code>")
|
51 |
-
|
52 |
-
|
53 |
-
)
|
54 |
-
|
55 |
-
|
56 |
-
x = response.choices[0].text
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
return x
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
# Function to elicit sql response from model
|
71 |
-
|
72 |
-
|
73 |
def greet(prompt):
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
sql = gpt3(txt)
|
80 |
-
|
81 |
-
|
82 |
-
return sql
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
|
95 |
#Code to set up Gradio UI
|
96 |
-
|
97 |
-
|
98 |
-
iface = gr.Interface(greet, inputs = ["text"], outputs = "text",title="Natural Language to SQL", description="Enter any prompt and get a SQL statement back! For better results, give it more context")
|
99 |
-
|
100 |
-
|
101 |
iface.launch()
|
102 |
|
|
|
1 |
import openai
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
|
|
|
|
3 |
import os
|
4 |
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
#OpenAi call
|
7 |
|
8 |
|
|
|
10 |
|
11 |
|
12 |
openai.api_key = os.environ["Secret"]
|
|
|
|
|
13 |
response = openai.Completion.create(
|
14 |
+
engine="code-davinci-002",
|
15 |
+
prompt= texts,
|
16 |
+
temperature=0,
|
17 |
+
max_tokens=750,
|
18 |
+
top_p=1,
|
19 |
+
frequency_penalty=0.0,
|
20 |
+
presence_penalty=0.0,
|
21 |
+
stop = (";", "#", "</code>")
|
22 |
+
)
|
23 |
+
x = response.choices[0].text
|
24 |
+
|
25 |
+
return x
|
26 |
+
|
27 |
+
# Function to elicit regex response from model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
def greet(prompt):
|
29 |
+
txt= (f'''Perfect Regex Generator \n #Prompt: {prompt}\n#Regex:\n''')
|
30 |
+
regex = gpt3(txt)
|
31 |
+
return regex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
|
34 |
#Code to set up Gradio UI
|
35 |
+
iface = gr.Interface(greet, inputs = ["text"], outputs = "text",title="Natural Language to Regex", description="Enter any prompt and get a regex statement back! For better results, give it more context")
|
|
|
|
|
|
|
|
|
36 |
iface.launch()
|
37 |
|