plutoa386 commited on
Commit
531ed6f
·
1 Parent(s): b8f2e67

fixed the returned news results object not being a json dict

Browse files
Files changed (1) hide show
  1. crew.py +7 -10
crew.py CHANGED
@@ -736,9 +736,8 @@ def run_crewai_news_patient(count: int = 5) -> dict:
736
  function_calling=True
737
  )
738
  result = crew.kickoff(inputs={"count": count})
739
- # result = gather_news_patient.run(count)
740
- # CrewAI returns ToolOutput → .raw or str — parse if needed
741
 
 
742
  try:
743
  return parse_json_from_markdown(str(result))
744
  except Exception as e:
@@ -752,11 +751,9 @@ def run_crewai_news_doctor(count: int = 5) -> dict:
752
  function_calling=False
753
  )
754
  result = crew.kickoff(inputs={"count": count})
755
- if isinstance(result, dict):
756
- return result
757
- else:
758
- try:
759
- import json
760
- return json.loads(str(result))
761
- except:
762
- return {"status": "error", "message": "Failed to parse crew output", "raw": str(result)}
 
736
  function_calling=True
737
  )
738
  result = crew.kickoff(inputs={"count": count})
 
 
739
 
740
+ # CrewAI returns ToolOutput → .raw or str — parse if needed
741
  try:
742
  return parse_json_from_markdown(str(result))
743
  except Exception as e:
 
751
  function_calling=False
752
  )
753
  result = crew.kickoff(inputs={"count": count})
754
+
755
+ # CrewAI returns ToolOutput → .raw or str — parse if needed
756
+ try:
757
+ return parse_json_from_markdown(str(result))
758
+ except Exception as e:
759
+ return {"status": "error", "message": f"Failed to parse crew output, <{e}>", "raw": result}