Kailxzz commited on
Commit
0170f28
1 Parent(s): 3540230

Update app.py

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