Hjgugugjhuhjggg commited on
Commit
08b4bf9
·
verified ·
1 Parent(s): 4fb8859

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -204,6 +204,19 @@ def get_best_response(responses):
204
  best_response_index = total_similarities.argmax()
205
  return responses[best_response_index]
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  async def process_message(message):
208
  inputs = normalize_input(message)
209
  with ThreadPoolExecutor() as executor:
 
204
  best_response_index = total_similarities.argmax()
205
  return responses[best_response_index]
206
 
207
+ async def generate_model_response(model, inputs, max_tokens=2048):
208
+ try:
209
+ response = model(inputs)
210
+ text = remove_duplicates(response['choices'][0]['text'])
211
+
212
+ if len(text.split()) > max_tokens:
213
+ parts = [text[i:i + max_tokens] for i in range(0, len(text), max_tokens)]
214
+ return ' '.join(parts)
215
+
216
+ return text
217
+ except Exception as e:
218
+ return ""
219
+
220
  async def process_message(message):
221
  inputs = normalize_input(message)
222
  with ThreadPoolExecutor() as executor: