Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,21 +27,21 @@ def write_elo_ratings(elo_ratings):
|
|
27 |
json.dump(elo_ratings, file, indent=4)
|
28 |
|
29 |
# Function to get bot response
|
30 |
-
def
|
31 |
-
|
32 |
for message in state["history"]:
|
33 |
j=""
|
34 |
if message['role']=='user':
|
35 |
j="### Instruction:\n"
|
36 |
else:
|
37 |
j="### Response:\n"
|
38 |
-
|
39 |
-
return
|
40 |
def get_bot_response(url, prompt,state):
|
41 |
-
|
42 |
payload = {
|
43 |
"input": {
|
44 |
-
"prompt":
|
45 |
"sampling_params": {
|
46 |
"max_new_tokens": 50,
|
47 |
"temperature": 0.7,
|
@@ -55,7 +55,7 @@ def get_bot_response(url, prompt,state):
|
|
55 |
"authorization": os.environ.get("RUNPOD_TOKEN")
|
56 |
}
|
57 |
response = requests.post(url, json=payload, headers=headers)
|
58 |
-
return response.json()['output'].split('
|
59 |
|
60 |
def chat_with_bots(user_input, state):
|
61 |
bot_names = list(chatbots.keys())
|
|
|
27 |
json.dump(elo_ratings, file, indent=4)
|
28 |
|
29 |
# Function to get bot response
|
30 |
+
def format_alpaca_prompt(state):
|
31 |
+
alpaca_prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
|
32 |
for message in state["history"]:
|
33 |
j=""
|
34 |
if message['role']=='user':
|
35 |
j="### Instruction:\n"
|
36 |
else:
|
37 |
j="### Response:\n"
|
38 |
+
alpaca_prompt += j+ message['content']+"\n\n"
|
39 |
+
return alpaca_prompt+"### Response:\n"
|
40 |
def get_bot_response(url, prompt,state):
|
41 |
+
alpaca_prompt = format_alpaca_prompt(state)
|
42 |
payload = {
|
43 |
"input": {
|
44 |
+
"prompt": alpaca+prompt,
|
45 |
"sampling_params": {
|
46 |
"max_new_tokens": 50,
|
47 |
"temperature": 0.7,
|
|
|
55 |
"authorization": os.environ.get("RUNPOD_TOKEN")
|
56 |
}
|
57 |
response = requests.post(url, json=payload, headers=headers)
|
58 |
+
return response.json()['output'].split('### Instruction')[0]
|
59 |
|
60 |
def chat_with_bots(user_input, state):
|
61 |
bot_names = list(chatbots.keys())
|