rwitz commited on
Commit
e675f6b
1 Parent(s): 5619ea2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -94,15 +94,14 @@ import asyncio
94
  from tenacity import retry, stop_after_attempt, wait_exponential
95
 
96
  async def get_bot_response(adapter_id, prompt, state, bot_index):
97
- alpaca_prompt = format_chatml_prompt(state)
98
- print(alpaca_prompt)
99
  payload = {
100
- "inputs": alpaca_prompt[bot_index],
101
  "parameters": {
102
  "adapter_id": adapter_id,
103
  "adapter_source": "hub",
104
  "temperature": 0.7,
105
- "stop":["<|im_end|>"],
106
  "max_new_tokens": 100
107
  }
108
  }
@@ -118,11 +117,12 @@ async def get_bot_response(adapter_id, prompt, state, bot_index):
118
  response_data = await response.json()
119
  response_text = response_data.get('generated_text', '')
120
  else:
121
- print(response.text)
 
122
  response_text = "Sorry, I couldn't generate a response."
123
  except (aiohttp.ClientError, asyncio.TimeoutError):
124
- response_text = "Sorry, I couldn't generate a response. Timeout"
125
- return response_text.split('### Instruction')[0]
126
  async def chat_with_bots(user_input, state):
127
  # Use existing bot order from state if available, otherwise shuffle and initialize
128
  if 'last_bots' not in state or not state['last_bots']:
 
94
  from tenacity import retry, stop_after_attempt, wait_exponential
95
 
96
  async def get_bot_response(adapter_id, prompt, state, bot_index):
97
+ chatml_prompt = format_chatml_prompt(state)
98
+ print(chatml_prompt)
99
  payload = {
100
+ "inputs": chatml_prompt[bot_index],
101
  "parameters": {
102
  "adapter_id": adapter_id,
103
  "adapter_source": "hub",
104
  "temperature": 0.7,
 
105
  "max_new_tokens": 100
106
  }
107
  }
 
117
  response_data = await response.json()
118
  response_text = response_data.get('generated_text', '')
119
  else:
120
+ error_text = await response.text()
121
+ print(error_text)
122
  response_text = "Sorry, I couldn't generate a response."
123
  except (aiohttp.ClientError, asyncio.TimeoutError):
124
+ response_text = "Sorry, I couldn't generate a response."
125
+ return response_text.split('<|im_end|>')[0].strip()
126
  async def chat_with_bots(user_input, state):
127
  # Use existing bot order from state if available, otherwise shuffle and initialize
128
  if 'last_bots' not in state or not state['last_bots']: