mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 15:43:54 +00:00
Fix openapi parameter parsing (#6676)
Ensure parameters are json serializable, related to #6671
This commit is contained in:
parent
b7e1c54947
commit
fa1bb873e2
@ -78,7 +78,7 @@ def _openapi_params_to_json_schema(params: List[Parameter], spec: OpenAPISpec) -
|
||||
schema = spec.get_schema(media_type_schema)
|
||||
if p.description and not schema.description:
|
||||
schema.description = p.description
|
||||
properties[p.name] = schema.dict(exclude_none=True)
|
||||
properties[p.name] = json.loads(schema.json(exclude_none=True))
|
||||
if p.required:
|
||||
required.append(p.name)
|
||||
return {"type": "object", "properties": properties, "required": required}
|
||||
@ -132,7 +132,9 @@ def openapi_spec_to_openai_fn(
|
||||
for media_type, media_type_object in request_body.content.items():
|
||||
if media_type_object.media_type_schema:
|
||||
schema = spec.get_schema(media_type_object.media_type_schema)
|
||||
media_types[media_type] = schema.dict(exclude_none=True)
|
||||
media_types[media_type] = json.loads(
|
||||
schema.json(exclude_none=True)
|
||||
)
|
||||
if len(media_types) == 1:
|
||||
media_type, schema_dict = list(media_types.items())[0]
|
||||
key = "json" if media_type == "application/json" else "data"
|
||||
|
Loading…
Reference in New Issue
Block a user