Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,40 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
import gradio as gr
|
4 |
+
|
5 |
+
url="https://huggingface.co/curiouscurrent/omnicode"
|
6 |
+
|
7 |
+
headers={
|
8 |
+
|
9 |
+
'Content-Type':'application/json'
|
10 |
+
}
|
11 |
+
|
12 |
+
history=[]
|
13 |
+
|
14 |
+
def generate_response(prompt):
|
15 |
+
history.append(prompt)
|
16 |
+
final_prompt="\n".join(history)
|
17 |
+
|
18 |
+
data={
|
19 |
+
"model":"curiouscurrent/omnicode",
|
20 |
+
"prompt":final_prompt,
|
21 |
+
"stream":False
|
22 |
+
}
|
23 |
+
|
24 |
+
response=requests.post(url,headers=headers,data=json.dumps(data))
|
25 |
+
|
26 |
+
if response.status_code==200:
|
27 |
+
response=response.text
|
28 |
+
data=json.loads(response)
|
29 |
+
actual_response=data['response']
|
30 |
+
return actual_response
|
31 |
+
else:
|
32 |
+
print("error:",response.text)
|
33 |
+
|
34 |
+
|
35 |
+
interface=gr.Interface(
|
36 |
+
fn=generate_response,
|
37 |
+
inputs=gr.Textbox(lines=4,placeholder="Enter your Prompt"),
|
38 |
+
outputs="text"
|
39 |
+
)
|
40 |
+
interface.launch()
|