@@ -28,9 +28,10 @@ def create_agent(self, name: str, description: str, goal: str) -> str:
2828 json = payload
2929 )
3030
31- response_json = response .json ()
3231 if response .status_code != 200 :
33- raise ValueError (f"Failed to post data: { response_json } " )
32+ raise ValueError (f"Failed to create agent (status { response .status_code } ). Response: { response .text } " )
33+
34+ response_json = response .json ()
3435
3536 return response_json ["data" ]["id" ]
3637
@@ -53,9 +54,10 @@ def create_workers(self, workers: List) -> str:
5354 json = payload
5455 )
5556
56- response_json = response .json ()
5757 if response .status_code != 200 :
58- raise ValueError (f"Failed to post data: { response_json } " )
58+ raise ValueError (f"Failed to get token (status { response .status_code } ). Response: { response .text } " )
59+
60+ response_json = response .json ()
5961
6062 return response_json ["data" ]["id" ]
6163
@@ -75,9 +77,10 @@ def set_worker_task(self, agent_id: str, task: str) -> Dict:
7577 json = payload
7678 )
7779
78- response_json = response .json ()
7980 if response .status_code != 200 :
80- raise ValueError (f"Failed to post data: { response_json } " )
81+ raise ValueError (f"Failed to set worker task (status { response .status_code } ). Response: { response .text } " )
82+
83+ response_json = response .json ()
8184
8285 return response_json ["data" ]
8386
@@ -93,9 +96,10 @@ def get_worker_action(self, agent_id: str, submission_id: str, data: dict) -> Di
9396 }
9497 )
9598
96- response_json = response .json ()
9799 if response .status_code != 200 :
98- raise ValueError (f"Failed to post data: { response_json } " )
100+ raise ValueError (f"Failed to get worker action (status { response .status_code } ). Response: { response .text } " )
101+
102+ response_json = response .json ()
99103
100104 return response_json ["data" ]
101105
@@ -111,8 +115,9 @@ def get_agent_action(self, agent_id: str, data: dict) -> Dict:
111115 }
112116 )
113117
114- response_json = response .json ()
115118 if response .status_code != 200 :
116- raise ValueError (f"Failed to post data: { response_json } " )
119+ raise ValueError (f"Failed to get agent action (status { response .status_code } ). Response: { response .text } " )
120+
121+ response_json = response .json ()
117122
118123 return response_json ["data" ]
0 commit comments