Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Vedantsahai18 opened this issue Sep 27, 2024 · 2 comments
Assignees

Comments

@Vedantsahai18
Copy link
Member

{
	"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'\"}}"
}
@whiterabbit1983
Copy link
Contributor

@creatorrr the error is caused by max_tokens in default_settings, it should not be here. The question is, how should this be fixed? Add better error message (default_settings validation maybe) ? Or strip all the extra fields from default_settings dict?

@whiterabbit1983
Copy link
Contributor

@creatorrr this issue has gone, create or update agent was still broken, but in other way, here's the fix #628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants