DeMaking commited on
Commit
1a16ecf
verified
1 Parent(s): 05cf5ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -14
app.py CHANGED
@@ -68,7 +68,6 @@ def generate_response(text):
68
  """
69
  language = detect_language(text)
70
  if language == "hebrew":
71
- # Hebrew prompt: answer shortly but explain your decision-making process
72
  content = "转砖诪讜专 注诇 转砖讜讘讛 拽爪专讛, 讗讘诇 转住驻专 讗讬讱 拽讬讘诇转 讗转 讛讛讞诇讟讛, " + text
73
  model = "huggingface/mistralai/Mistral-Nemo-Instruct-2407" # "yam-peleg/Hebrew-Gemma-11B-Instruct"
74
  elif language == "english":
@@ -79,25 +78,15 @@ def generate_response(text):
79
 
80
  messages = [{"role": "user", "content": content}]
81
 
82
- # try:
83
- # completion = client.chat.completions.create(
84
- # model=model,
85
- # messages=messages,
86
- # max_tokens=2048,
87
- # temperature=0.5,
88
- # top_p=0.7
89
- # )
90
- # return completion.choices[0].message.content
91
  try:
92
- completion_res = completions(
93
  model=model,
94
  messages=messages,
95
- max_tokens=200,
96
  temperature=0.5,
97
  top_p=0.7
98
  )
99
- print(f"completion_res: {completion_res}")
100
- return completion_res
101
  except Exception as e:
102
  logger.error(f"Error generating response: {e}")
103
  return "Error: Could not generate response."
 
68
  """
69
  language = detect_language(text)
70
  if language == "hebrew":
 
71
  content = "转砖诪讜专 注诇 转砖讜讘讛 拽爪专讛, 讗讘诇 转住驻专 讗讬讱 拽讬讘诇转 讗转 讛讛讞诇讟讛, " + text
72
  model = "huggingface/mistralai/Mistral-Nemo-Instruct-2407" # "yam-peleg/Hebrew-Gemma-11B-Instruct"
73
  elif language == "english":
 
78
 
79
  messages = [{"role": "user", "content": content}]
80
 
 
 
 
 
 
 
 
 
 
81
  try:
82
+ completion = client.chat.completions.create(
83
  model=model,
84
  messages=messages,
85
+ max_tokens=2048,
86
  temperature=0.5,
87
  top_p=0.7
88
  )
89
+ return completion.choices[0].message.content
 
90
  except Exception as e:
91
  logger.error(f"Error generating response: {e}")
92
  return "Error: Could not generate response."