Almaatla commited on
Commit
f219c08
1 Parent(s): 910153c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -428,20 +428,26 @@ def ask_gpt(query, apikey,history,ui_session_id):
428
  def gpt_answer(api_key, query, model="gpt-3.5-turbo-1106", system_prompt="Use the provided References to answer the user Question. If the provided document do not contain the elements to answer the user question, just say 'No information.'."):
429
  if 'gpt' in model:
430
  client = OpenAI( api_key=api_key)
431
-
 
 
 
 
 
 
 
 
 
 
432
  if 'mistral' in model:
433
  client = MistralClient(api_key=api_key)
434
-
435
- chat_completion = client.chat.completions.create(
436
- messages=[
437
- {"role": "system", "content": system_prompt},
438
- {"role": "user", "content": query},
439
-
440
- ],
441
- model=model,
442
- )
443
- return chat_completion.choices[0].message.content
444
-
445
 
446
 
447
  def add_line_breaks(input_string, line_length=100):
 
428
  def gpt_answer(api_key, query, model="gpt-3.5-turbo-1106", system_prompt="Use the provided References to answer the user Question. If the provided document do not contain the elements to answer the user question, just say 'No information.'."):
429
  if 'gpt' in model:
430
  client = OpenAI( api_key=api_key)
431
+
432
+ chat_completion = client.chat.completions.create(
433
+ messages=[
434
+ {"role": "system", "content": system_prompt},
435
+ {"role": "user", "content": query},
436
+
437
+ ],
438
+ model=model,
439
+ )
440
+ return chat_completion.choices[0].message.content
441
+
442
  if 'mistral' in model:
443
  client = MistralClient(api_key=api_key)
444
+ chat_response = client.chat(
445
+ model=model,
446
+ messages=[
447
+ ChatMessage(role="system", content=system_prompt),
448
+ ChatMessage(role="user", content=query)],
449
+ )
450
+ return chat_response.choices[0].message.content
 
 
 
 
451
 
452
 
453
  def add_line_breaks(input_string, line_length=100):