Update app.py
Browse files
app.py
CHANGED
|
@@ -37,14 +37,16 @@ def generate_response(text):
|
|
| 37 |
language = detect_language(text)
|
| 38 |
print(f"Detected language: {language}, ", f"current time: {current_time_gmt()}")
|
| 39 |
|
| 40 |
-
if language == "hebrew" or language == "english":
|
|
|
|
|
|
|
| 41 |
messages = [
|
| 42 |
-
{ "role": "user", "content":
|
| 43 |
]
|
| 44 |
print(f"Messages: {messages}, ", f"current time: {current_time_gmt()}")
|
| 45 |
|
| 46 |
completion = client.chat.completions.create(
|
| 47 |
-
model="
|
| 48 |
# model="microsoft/Phi-3.5-mini-instruct", # good in english. not so good in hebrew
|
| 49 |
messages=messages,
|
| 50 |
max_tokens=2048,
|
|
@@ -53,6 +55,22 @@ def generate_response(text):
|
|
| 53 |
)
|
| 54 |
#print("\ncompletion: ", completion.choices[0].message.content, f"\ncurrent time: {current_time_gmt()}")
|
| 55 |
return completion.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
return "Sorry, I only support Hebrew and English."
|
| 58 |
|
|
|
|
| 37 |
language = detect_language(text)
|
| 38 |
print(f"Detected language: {language}, ", f"current time: {current_time_gmt()}")
|
| 39 |
|
| 40 |
+
if language == "hebrew": # or language == "english":
|
| 41 |
+
content = "转注谞讛 讘拽爪专讛 讗讘诇 转砖转祝 讗转 转讛诇讬讱 拽讘诇转 讛讛讞诇讟讜转 砖诇讱, " + text
|
| 42 |
+
print("content: ", content)
|
| 43 |
messages = [
|
| 44 |
+
{ "role": "user", "content": content }
|
| 45 |
]
|
| 46 |
print(f"Messages: {messages}, ", f"current time: {current_time_gmt()}")
|
| 47 |
|
| 48 |
completion = client.chat.completions.create(
|
| 49 |
+
model="onlplab/alephbert-base",
|
| 50 |
# model="microsoft/Phi-3.5-mini-instruct", # good in english. not so good in hebrew
|
| 51 |
messages=messages,
|
| 52 |
max_tokens=2048,
|
|
|
|
| 55 |
)
|
| 56 |
#print("\ncompletion: ", completion.choices[0].message.content, f"\ncurrent time: {current_time_gmt()}")
|
| 57 |
return completion.choices[0].message.content
|
| 58 |
+
elif language == "english":
|
| 59 |
+
content = "keep it short but tell your decision making process, " + text
|
| 60 |
+
print("content: ", content)
|
| 61 |
+
messages = [
|
| 62 |
+
{ "role": "user", "content": content }
|
| 63 |
+
]
|
| 64 |
+
print(f"Messages: {messages}, ", f"current time: {current_time_gmt()}")
|
| 65 |
+
|
| 66 |
+
completion = client.chat.completions.create(
|
| 67 |
+
model="mistralai/Mistral-Nemo-Instruct-2407",
|
| 68 |
+
messages=messages,
|
| 69 |
+
max_tokens=2048,
|
| 70 |
+
temperature=0.5,
|
| 71 |
+
top_p=0.7
|
| 72 |
+
)
|
| 73 |
+
return completion.choices[0].message.content
|
| 74 |
|
| 75 |
return "Sorry, I only support Hebrew and English."
|
| 76 |
|