Nada
commited on
Commit
·
75ab808
1
Parent(s):
4406616
Update
Browse files- conversation_flow.py +6 -6
conversation_flow.py
CHANGED
|
@@ -247,8 +247,8 @@ class FlowManager:
|
|
| 247 |
response = self.llm.invoke(prompt)
|
| 248 |
|
| 249 |
try:
|
| 250 |
-
# Parse with
|
| 251 |
-
evaluation =
|
| 252 |
# Validate with Pydantic
|
| 253 |
phase_transition = PhaseTransitionResponse.parse_obj(evaluation)
|
| 254 |
|
|
@@ -261,7 +261,7 @@ class FlowManager:
|
|
| 261 |
if phase_transition.should_transition:
|
| 262 |
if phase_transition.next_phase in self.PHASES:
|
| 263 |
self._transition_to_phase(user_id, phase_transition.next_phase, phase_transition.reasoning)
|
| 264 |
-
except (
|
| 265 |
self._check_time_based_transition(user_id)
|
| 266 |
|
| 267 |
def _check_time_based_transition(self, user_id: str):
|
|
@@ -378,13 +378,13 @@ class FlowManager:
|
|
| 378 |
response = self.llm.invoke(prompt)
|
| 379 |
|
| 380 |
try:
|
| 381 |
-
# Parse with
|
| 382 |
-
characteristics =
|
| 383 |
# Validate with Pydantic
|
| 384 |
session_chars = SessionCharacteristics.parse_obj(characteristics)
|
| 385 |
session['llm_context']['session_characteristics'] = session_chars.dict()
|
| 386 |
logger.info(f"Updated session characteristics for user {user_id}")
|
| 387 |
-
except (
|
| 388 |
logger.warning(f"Failed to parse session characteristics: {e}")
|
| 389 |
|
| 390 |
def _create_flow_context(self, user_id: str) -> Dict[str, Any]:
|
|
|
|
| 247 |
response = self.llm.invoke(prompt)
|
| 248 |
|
| 249 |
try:
|
| 250 |
+
# Parse with standard json
|
| 251 |
+
evaluation = json.loads(response)
|
| 252 |
# Validate with Pydantic
|
| 253 |
phase_transition = PhaseTransitionResponse.parse_obj(evaluation)
|
| 254 |
|
|
|
|
| 261 |
if phase_transition.should_transition:
|
| 262 |
if phase_transition.next_phase in self.PHASES:
|
| 263 |
self._transition_to_phase(user_id, phase_transition.next_phase, phase_transition.reasoning)
|
| 264 |
+
except (json.JSONDecodeError, ValueError):
|
| 265 |
self._check_time_based_transition(user_id)
|
| 266 |
|
| 267 |
def _check_time_based_transition(self, user_id: str):
|
|
|
|
| 378 |
response = self.llm.invoke(prompt)
|
| 379 |
|
| 380 |
try:
|
| 381 |
+
# Parse with standard json
|
| 382 |
+
characteristics = json.loads(response)
|
| 383 |
# Validate with Pydantic
|
| 384 |
session_chars = SessionCharacteristics.parse_obj(characteristics)
|
| 385 |
session['llm_context']['session_characteristics'] = session_chars.dict()
|
| 386 |
logger.info(f"Updated session characteristics for user {user_id}")
|
| 387 |
+
except (json.JSONDecodeError, ValueError) as e:
|
| 388 |
logger.warning(f"Failed to parse session characteristics: {e}")
|
| 389 |
|
| 390 |
def _create_flow_context(self, user_id: str) -> Dict[str, Any]:
|