File size: 898 Bytes
5187986
20eb013
 
 
 
5187986
20eb013
 
5187986
 
20eb013
 
 
 
 
0dbfe6b
5187986
20eb013
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5187986
20eb013
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5187986
 
 
20eb013
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import openai




import gradio as gr


import os







#OpenAi call


def gpt3(texts):


   openai.api_key = os.environ["Secret"]


   response = openai.Completion.create(


     engine="code-davinci-002",


     prompt= texts,


         temperature=0,


         max_tokens=750,


         top_p=1,


         frequency_penalty=0.0,


         presence_penalty=0.0,


         stop = (";", "/*", "</code>")


   )


   x = response.choices[0].text


  


   return x







# Function to elicit sql response from model


def greet(prompt):


   txt= (f'''/*Prompt: {prompt}*/ \n —-SQL Code:\n''')


   sql = gpt3(txt)


   return sql












#Code to set up Gradio UI


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


iface.launch()