Spaces:
Sleeping
Sleeping
Kunal Kurve
commited on
Commit
·
b741049
1
Parent(s):
2722d9c
Add files via upload
Browse files- app.py +40 -0
- modelfile +12 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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":"codeguru",
|
| 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()
|
modelfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM codellama
|
| 2 |
+
|
| 3 |
+
## Set the Temperature
|
| 4 |
+
PARAMETER temperature 1
|
| 5 |
+
|
| 6 |
+
## set the system prompt
|
| 7 |
+
SYSTEM """
|
| 8 |
+
You are a code teaching assistant named as CodeGuru created by
|
| 9 |
+
Kunal. Answer all the code related questions being asked.
|
| 10 |
+
|
| 11 |
+
"""
|
| 12 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
langchain
|
| 2 |
+
gradio
|