Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -82,24 +82,20 @@ import os
|
|
82 |
|
83 |
|
84 |
# Function to get bot response
|
85 |
-
def
|
86 |
-
|
87 |
-
|
88 |
for message in state["history"][0]:
|
89 |
-
|
90 |
-
|
91 |
-
j="### Instruction:\n"
|
92 |
else:
|
93 |
-
|
94 |
-
alpaca_prompt += j+ message['content']+"\n\n"
|
95 |
for message in state["history"][1]:
|
96 |
-
|
97 |
-
|
98 |
-
j="### Instruction:\n"
|
99 |
else:
|
100 |
-
|
101 |
-
|
102 |
-
return [alpaca_prompt+"### Response:\n",alpaca_prompt2+"### Response:\n"]
|
103 |
import aiohttp
|
104 |
import asyncio
|
105 |
from tenacity import retry, stop_after_attempt, wait_exponential
|
|
|
82 |
|
83 |
|
84 |
# Function to get bot response
|
85 |
+
def format_chatml_prompt(state):
|
86 |
+
chatml_prompt = "<|im_start|>system You are a helpful assistant, who can think outside the box.<|im_end|>"
|
87 |
+
chatml_prompt2 = "<|im_start|>system You are a helpful assistant, who can think outside the box.<|im_end|>"
|
88 |
for message in state["history"][0]:
|
89 |
+
if message['role'] == 'user':
|
90 |
+
chatml_prompt += "\n<|im_start|>user " + message['content'] + "<|im_end|>"
|
|
|
91 |
else:
|
92 |
+
chatml_prompt += "\n<|im_start|>assistant " + message['content'] + "<|im_end|>"
|
|
|
93 |
for message in state["history"][1]:
|
94 |
+
if message['role'] == 'user':
|
95 |
+
chatml_prompt2 += "\n<|im_start|>user " + message['content'] + "<|im_end|>"
|
|
|
96 |
else:
|
97 |
+
chatml_prompt2 += "\n<|im_start|>assistant " + message['content'] + "<|im_end|>"
|
98 |
+
return [chatml_prompt + "\n<|im_start|>assistant", chatml_prompt2 + "\n<|im_start|>assistant"]
|
|
|
99 |
import aiohttp
|
100 |
import asyncio
|
101 |
from tenacity import retry, stop_after_attempt, wait_exponential
|