Kabil007 commited on
Commit
46d7d25
·
verified ·
1 Parent(s): 83d513b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+ import gradio as gr
4
+
5
+
6
+ url = "http://localhost:11434/api/generate"
7
+
8
+
9
+ headers = {
10
+ 'content-type' :'application/json'
11
+ }
12
+
13
+ history = []
14
+
15
+ def generate_code(prompt):
16
+ history.append(prompt)
17
+ final_prompt = "\n".join(history)
18
+
19
+ data={
20
+ 'model': 'azuna',
21
+ 'prompt': final_prompt,
22
+ 'stream' : False
23
+ }
24
+
25
+ response = requests.post(url,headers = headers, data = json.dumps(data))
26
+
27
+ if response.status_code == 200:
28
+ response = response.text
29
+ data = json.loads(response)
30
+ actual_response = data['response']
31
+ return actual_response
32
+ else:
33
+ print("Error:", response.text)
34
+
35
+
36
+ Interface = gr.Interface(
37
+ fn = generate_code,
38
+ inputs= gr.Textbox(lines=5, placeholder="Enter the prompt here."),
39
+ outputs= "text"
40
+ )
41
+ Interface.launch(share=True)