julep-ai / julep

Build AI agents and workflows with a simple API. Supabase for AI agents
https://julep.ai
Apache License 2.0
883 stars 69 forks source link

Fix client.agents.create_or_update SDK: Bad Request Error when providing a default settings dictionary as an argument #526

Open Vedantsahai18 opened 6 days ago

Vedantsahai18 commented 6 days ago
{
    "name": "BadRequestError",
    "message": "Error code: 400 - {'error': {'message': \"400: when executing against relation 'agent_default_settings'\"}}",
    "stack": "---------------------------------------------------------------------------
BadRequestError                           Traceback (most recent call last)
Cell In[19], line 16
      4 default_settings = {
      5     \"temperature\": 0.7,
      6     \"top_p\": 1,
   (...)
     11     \"max_tokens\": 150,
     12 }
     15 # Create the agent
---> 16 agent = client.agents.create_or_update(
     17     agent_id=AGENT_UUID,
     18     name=name,
     19     about=about,
     20     model=\"gpt-4o\",
     21     default_settings=default_settings
     22 )

File ~/miniconda3/envs/ai/lib/python3.11/site-packages/julep/resources/agents/agents.py:300, in AgentsResource.create_or_update(self, agent_id, about, default_settings, instructions, metadata, model, name, extra_headers, extra_query, extra_body, timeout)
    298 if not agent_id:
    299     raise ValueError(f\"Expected a non-empty value for `agent_id` but received {agent_id!r}\")
--> 300 return self._post(
    301     f\"/agents/{agent_id}\",
    302     body=maybe_transform(
    303         {
    304             \"about\": about,
    305             \"default_settings\": default_settings,
    306             \"instructions\": instructions,
    307             \"metadata\": metadata,
    308             \"model\": model,
    309             \"name\": name,
    310         },
    311         agent_create_or_update_params.AgentCreateOrUpdateParams,
    312     ),
    313     options=make_request_options(
    314         extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
    315     ),
    316     cast_to=ResourceCreated,
    317 )

File ~/miniconda3/envs/ai/lib/python3.11/site-packages/julep/_base_client.py:1254, in SyncAPIClient.post(self, path, cast_to, body, options, files, stream, stream_cls)
   1240 def post(
   1241     self,
   1242     path: str,
   (...)
   1249     stream_cls: type[_StreamT] | None = None,
   1250 ) -> ResponseT | _StreamT:
   1251     opts = FinalRequestOptions.construct(
   1252         method=\"post\", url=path, json_data=body, files=to_httpx_files(files), **options
   1253     )
-> 1254     return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))

File ~/miniconda3/envs/ai/lib/python3.11/site-packages/julep/_base_client.py:946, in SyncAPIClient.request(self, cast_to, options, remaining_retries, stream, stream_cls)
    943 else:
    944     retries_taken = 0
--> 946 return self._request(
    947     cast_to=cast_to,
    948     options=options,
    949     stream=stream,
    950     stream_cls=stream_cls,
    951     retries_taken=retries_taken,
    952 )

File ~/miniconda3/envs/ai/lib/python3.11/site-packages/julep/_base_client.py:1049, in SyncAPIClient._request(self, cast_to, options, retries_taken, stream, stream_cls)
   1046         err.response.read()
   1048     log.debug(\"Re-raising status error\")
-> 1049     raise self._make_status_error_from_response(err.response) from None
   1051 return self._process_response(
   1052     cast_to=cast_to,
   1053     options=options,
   (...)
   1057     retries_taken=retries_taken,
   1058 )

BadRequestError: Error code: 400 - {'error': {'message': \"400: when executing against relation 'agent_default_settings'\"}}"
}