Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,8 @@ from smolagents import HfApiModel
|
|
5 |
|
6 |
|
7 |
model = HfApiModel(model_id="mistralai/Mixtral-8x7B-Instruct-v0.1", token=os.environ.get("HF_TOKEN"))
|
8 |
-
|
9 |
-
|
10 |
-
data = [
|
11 |
-
{
|
12 |
"role":"system",
|
13 |
"content":[
|
14 |
{
|
@@ -16,7 +14,11 @@ def chat(prompt, history):
|
|
16 |
"text": "You are a doctor who specializes on helping patients with addiction issues"
|
17 |
}
|
18 |
]
|
19 |
-
}
|
|
|
|
|
|
|
|
|
20 |
{
|
21 |
"role":"user",
|
22 |
"content":[
|
@@ -27,8 +29,24 @@ def chat(prompt, history):
|
|
27 |
]
|
28 |
}
|
29 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
return model(
|
32 |
|
33 |
demo = gr.ChatInterface(chat, title="ArunGPT",theme = gr.themes.Soft(), description="Hello this is chatbot is created for only educational purpose and is powered by mistral 8x 7b model").queue()
|
34 |
|
|
|
5 |
|
6 |
|
7 |
model = HfApiModel(model_id="mistralai/Mixtral-8x7B-Instruct-v0.1", token=os.environ.get("HF_TOKEN"))
|
8 |
+
system_data = [
|
9 |
+
{
|
|
|
|
|
10 |
"role":"system",
|
11 |
"content":[
|
12 |
{
|
|
|
14 |
"text": "You are a doctor who specializes on helping patients with addiction issues"
|
15 |
}
|
16 |
]
|
17 |
+
}
|
18 |
+
]
|
19 |
+
|
20 |
+
def get_user_data(prompt: str):
|
21 |
+
return [
|
22 |
{
|
23 |
"role":"user",
|
24 |
"content":[
|
|
|
29 |
]
|
30 |
}
|
31 |
]
|
32 |
+
|
33 |
+
def get_history(history):
|
34 |
+
mod_history = []
|
35 |
+
for i in history:
|
36 |
+
d = {}
|
37 |
+
d["role"] = i["role"]
|
38 |
+
d["content"] = [
|
39 |
+
{
|
40 |
+
"type": "text",
|
41 |
+
"text": i["content"]
|
42 |
+
}
|
43 |
+
]
|
44 |
+
mod_history.append(d)
|
45 |
+
return mod_history
|
46 |
+
|
47 |
+
def chat(prompt, history):
|
48 |
|
49 |
+
return model(system_data + get_history(history)+ get_user_data(prompt)).content
|
50 |
|
51 |
demo = gr.ChatInterface(chat, title="ArunGPT",theme = gr.themes.Soft(), description="Hello this is chatbot is created for only educational purpose and is powered by mistral 8x 7b model").queue()
|
52 |
|