-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
41 lines (34 loc) · 1.24 KB
/
app.py
File metadata and controls
41 lines (34 loc) · 1.24 KB
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
import requests
import json
import gradio as gr
url="http://localhost:11434/api/generate"
headers={
'Content-Type':'application/json'
}
history=[]
def generate_response(Prompt):
history.append(Prompt)
final_prompt="\n".join(history)
data={
"model":"codesensei",
"Prompt":final_prompt,
"stream":False
}
response=requests.post(url,headers=headers,data=json.dumps(data))
if response.status_code==200:
response=response.text
data=json.loads(response)
actual_response=data['response']
return actual_response
else:
print("error:",response.text)
interface = gr.Interface(
fn=generate_response, # Function to be called for prediction
inputs=gr.Textbox(lines=2, placeholder="Enter your Prompt"), # Input textbox
outputs="text", # Output display
title="CodeSensei", # Title of the interface
description='''CodeSensei is an A.I. assistant designed to help you with coding tasks and questions. ggi
Just enter your code or query in the textbox above, and CodeSensei will provide you with helpful responses and insights.''', # Description of the interface
theme="HaleyCH/HaleyCH_Theme", # Theme for better visualization
)
interface.launch()