Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,10 +27,16 @@ def write_elo_ratings(elo_ratings):
|
|
27 |
json.dump(elo_ratings, file, indent=4)
|
28 |
|
29 |
# Function to get bot response
|
|
|
|
|
|
|
|
|
|
|
30 |
def get_bot_response(url, prompt):
|
|
|
31 |
payload = {
|
32 |
"input": {
|
33 |
-
"prompt":
|
34 |
"sampling_params": {
|
35 |
"max_new_tokens": 50,
|
36 |
"temperature": 0.7,
|
@@ -101,7 +107,6 @@ def user_ask(state, chatbot1, chatbot2, textbox):
|
|
101 |
state["history"] = state["history"][-10:]
|
102 |
|
103 |
# Format the conversation in ChatML format
|
104 |
-
chatml_prompt = format_chatml_prompt(state)
|
105 |
|
106 |
return state, chatbot1, chatbot2, textbox
|
107 |
|
|
|
27 |
json.dump(elo_ratings, file, indent=4)
|
28 |
|
29 |
# Function to get bot response
|
30 |
+
def format_chatml_prompt(state):
|
31 |
+
chatml_prompt = ""
|
32 |
+
for message in state.get("history", []):
|
33 |
+
chatml_prompt += f"{:<|im_start|> "+message['role']}+"- "+ {message['content']}+"<|im_end|>\n"
|
34 |
+
return chatml_prompt
|
35 |
def get_bot_response(url, prompt):
|
36 |
+
chatml_prompt = format_chatml_prompt(state)
|
37 |
payload = {
|
38 |
"input": {
|
39 |
+
"prompt": chatml_prompt,
|
40 |
"sampling_params": {
|
41 |
"max_new_tokens": 50,
|
42 |
"temperature": 0.7,
|
|
|
107 |
state["history"] = state["history"][-10:]
|
108 |
|
109 |
# Format the conversation in ChatML format
|
|
|
110 |
|
111 |
return state, chatbot1, chatbot2, textbox
|
112 |
|