Find the index of the simplest cURL command from a list
(self, request_list: List[Request])
| 249 | return state |
| 250 | |
| 251 | def get_simplest_request(self, request_list: List[Request]) -> Request: |
| 252 | """ |
| 253 | Find the index of the simplest cURL command from a list |
| 254 | """ |
| 255 | function_def = { |
| 256 | "name": "get_simplest_curl_index", |
| 257 | "description": "Find the index of the simplest cURL command from a list", |
| 258 | "parameters": { |
| 259 | "type": "object", |
| 260 | "properties": { |
| 261 | "index": { |
| 262 | "type": "integer", |
| 263 | "description": "The index of the simplest cURL command in the list" |
| 264 | } |
| 265 | }, |
| 266 | "required": ["index"] |
| 267 | } |
| 268 | } |
| 269 | # convert request objects to strings |
| 270 | serializable_list = [str(req) for req in request_list] |
| 271 | |
| 272 | prompt = f""" |
| 273 | {json.dumps(serializable_list)} |
| 274 | Task: |
| 275 | Given the above list of cURL commands, find the index of the curl that has the least number of dependencies and variables. |
| 276 | The index should be 0-based (i.e., the first item has index 0). |
| 277 | """ |
| 278 | |
| 279 | response = llm.get_instance().invoke( |
| 280 | prompt, |
| 281 | functions=[function_def], |
| 282 | function_call={"name": "get_simplest_curl_index"} |
| 283 | ) |
| 284 | |
| 285 | function_call = response.additional_kwargs['function_call'] |
| 286 | simplest_curl_index = json.loads(function_call['arguments'])['index'] |
| 287 | |
| 288 | # Retrieve the actual cURL command using the index |
| 289 | simplest_curl = request_list[simplest_curl_index] |
| 290 | return simplest_curl |
| 291 | |
| 292 | def find_curl_from_content(self, state: AgentState) -> AgentState: |
| 293 | """ |
no test coverage detected