Spaces:
Sleeping
Sleeping
Upload llm_engine.py
Browse files
app/services/llm_engine.py
CHANGED
|
@@ -183,14 +183,14 @@ class LLMEngine:
|
|
| 183 |
try:
|
| 184 |
# Perhatikan: Kita panggil _execute_with_retry, bukan self.client.create
|
| 185 |
response_content = await self._execute_with_retry(
|
| 186 |
-
messages=
|
| 187 |
-
model="llama-3.
|
| 188 |
-
|
| 189 |
)
|
| 190 |
-
return response_content
|
| 191 |
-
|
| 192 |
except Exception as e:
|
| 193 |
-
|
|
|
|
| 194 |
|
| 195 |
async def casual_chat(self, user_text: str, history: list = [], is_role_empty: bool = False):
|
| 196 |
|
|
@@ -275,7 +275,7 @@ class LLMEngine:
|
|
| 275 |
model="llama-3.1-8b-instant",
|
| 276 |
temperature=0.7
|
| 277 |
)
|
| 278 |
-
except:
|
| 279 |
print(f"ERROR Psych Analyze: {e}")
|
| 280 |
return f"Kamu cocok jadi {role}!"
|
| 281 |
|
|
|
|
| 183 |
try:
|
| 184 |
# Perhatikan: Kita panggil _execute_with_retry, bukan self.client.create
|
| 185 |
response_content = await self._execute_with_retry(
|
| 186 |
+
messages=[{"role": "user", "content": prompt}],
|
| 187 |
+
model="llama-3.3-70b-versatile",
|
| 188 |
+
response_format={"type": "json_object"}
|
| 189 |
)
|
| 190 |
+
return json.loads(response_content)
|
|
|
|
| 191 |
except Exception as e:
|
| 192 |
+
print(f"ERROR Evaluate answer: {e}")
|
| 193 |
+
return {"score": 0, "feedback": "Error menilai.", "is_correct": False}
|
| 194 |
|
| 195 |
async def casual_chat(self, user_text: str, history: list = [], is_role_empty: bool = False):
|
| 196 |
|
|
|
|
| 275 |
model="llama-3.1-8b-instant",
|
| 276 |
temperature=0.7
|
| 277 |
)
|
| 278 |
+
except Exception as e:
|
| 279 |
print(f"ERROR Psych Analyze: {e}")
|
| 280 |
return f"Kamu cocok jadi {role}!"
|
| 281 |
|