You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/praisonai-agents/praisonaiagents/process/process.py
+48-14Lines changed: 48 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@
8
8
from ..mainimportdisplay_error, client
9
9
importcsv
10
10
importos
11
+
fromopenaiimportAsyncOpenAI
11
12
12
13
classLoopItems(BaseModel):
13
14
items: List[Any]
@@ -116,12 +117,24 @@ async def _get_manager_instructions_with_fallback_async(self, manager_task, mana
116
117
logging.info(f"Structured output failed: {e}, falling back to JSON mode...")
117
118
# Fallback to regular JSON mode
118
119
try:
119
-
enhanced_prompt=manager_prompt+"\n\nIMPORTANT: Respond with valid JSON only, using this exact structure: {\"task_id\": <int>, \"agent_name\": \"<string>\", \"action\": \"<execute or stop>\"}"
120
+
# Generate JSON structure description from Pydantic model
enhanced_prompt=manager_prompt+f"\n\nIMPORTANT: Respond with valid JSON only, using this exact structure: {json_structure_desc}{required_desc}"
128
+
exceptExceptionasschema_error:
129
+
logging.warning(f"Could not generate schema for ManagerInstructions: {schema_error}. Using hardcoded prompt.")
130
+
# Fallback to hardcoded prompt if schema generation fails
131
+
enhanced_prompt=manager_prompt+"\n\nIMPORTANT: Respond with valid JSON only, using this exact structure: {\"task_id\": <int>, \"agent_name\": \"<string>\", \"action\": \"<execute or stop>\"}"
logging.info(f"Structured output failed: {e}, falling back to JSON mode...")
143
156
# Fallback to regular JSON mode
144
157
try:
145
-
enhanced_prompt=manager_prompt+"\n\nIMPORTANT: Respond with valid JSON only, using this exact structure: {\"task_id\": <int>, \"agent_name\": \"<string>\", \"action\": \"<execute or stop>\"}"
158
+
# Generate JSON structure description from Pydantic model
enhanced_prompt=manager_prompt+f"\n\nIMPORTANT: Respond with valid JSON only, using this exact structure: {json_structure_desc}{required_desc}"
166
+
exceptExceptionasschema_error:
167
+
logging.warning(f"Could not generate schema for ManagerInstructions: {schema_error}. Using hardcoded prompt.")
168
+
# Fallback to hardcoded prompt if schema generation fails
169
+
enhanced_prompt=manager_prompt+"\n\nIMPORTANT: Respond with valid JSON only, using this exact structure: {\"task_id\": <int>, \"agent_name\": \"<string>\", \"action\": \"<execute or stop>\"}"
0 commit comments