rwitz commited on
Commit
5b6eec5
1 Parent(s): 21e2ad0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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 format_chatml_prompt(state):
31
- chatml_prompt = ""
32
  for message in state["history"]:
33
  j=""
34
  if message['role']=='user':
35
  j="### Instruction:\n"
36
  else:
37
  j="### Response:\n"
38
- chatml_prompt += j+ message['content']+"\n\n"
39
- return chatml_prompt+"|im_start|Assistant: "
40
  def get_bot_response(url, prompt,state):
41
- chatml_prompt = format_chatml_prompt(state)
42
  payload = {
43
  "input": {
44
- "prompt": chatml_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('|im_end|')[0]
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())