Skip to content

Commit

Permalink
update 'data' param to 'body_data'
Browse files Browse the repository at this point in the history
In testing it seems that using 'data' resulted in the LLM not wrapping the parameters. No idea why.
  • Loading branch information
snopoke committed Nov 8, 2024
1 parent 6235e8e commit d9d8f50
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/chat/agent/openapi_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def call_api(self, **kwargs) -> Any:
path_params: path params
headers: headers
cookies: cookies
data: request body
body_data: request body
All of these will be pydantic models.
Expand All @@ -59,8 +59,8 @@ def call_api(self, **kwargs) -> Any:
method = self.function_def.method
path_params = kwargs.pop("path_params", None)

if "data" in kwargs:
kwargs["json"] = kwargs.pop("data")
if "body_data" in kwargs:
kwargs["json"] = kwargs.pop("body_data")

kwargs = {k: v.model_dump() if isinstance(v, BaseModel) else v for k, v in kwargs.items()}

Expand Down Expand Up @@ -109,7 +109,7 @@ class GetWeatherModel(BaseModel):
path_params: PathParamsModel
headers: HeadersModel
cookies: CookiesModel
data: BodyModel
body_data: BodyModel
"""

op = spec.get_operation(path, method)
Expand Down Expand Up @@ -138,8 +138,9 @@ class GetWeatherModel(BaseModel):
if request_body and request_body.content:
if "application/json" in request_body.content:
schema = spec.get_schema(request_body.content["application/json"].media_type_schema)
schema.title = "body"
request_args["data"] = _schema_to_pydantic_field_type(spec, schema)
# note: This was changed from 'data' because it seems to work better :shrug:
schema.title = "body_data"
request_args["body_data"] = _schema_to_pydantic_field_type(spec, schema)
else:
raise ValueError("Only application/json request bodies are supported")

Expand Down

0 comments on commit d9d8f50

Please sign in to comment.