Home / Function/ _openapi_params_to_json_schema() — langchain Function Reference

_openapi_params_to_json_schema() — langchain Function Reference

Architecture documentation for the _openapi_params_to_json_schema() function in openapi.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  41b94abf_e2df_df94_e64d_82534fc220a8["_openapi_params_to_json_schema()"]
  a34d3b0d_246d_bf4f_cf5f_c38a4937926e["openapi.py"]
  41b94abf_e2df_df94_e64d_82534fc220a8 -->|defined in| a34d3b0d_246d_bf4f_cf5f_c38a4937926e
  174ab5ce_1945_87e8_8e93_22af84e01f0a["openapi_spec_to_openai_fn()"]
  174ab5ce_1945_87e8_8e93_22af84e01f0a -->|calls| 41b94abf_e2df_df94_e64d_82534fc220a8
  style 41b94abf_e2df_df94_e64d_82534fc220a8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/openai_functions/openapi.py lines 69–83

def _openapi_params_to_json_schema(params: list[Parameter], spec: OpenAPISpec) -> dict:
    properties = {}
    required = []
    for p in params:
        if p.param_schema:
            schema = spec.get_schema(p.param_schema)
        else:
            media_type_schema = next(iter(p.content.values())).media_type_schema
            schema = spec.get_schema(media_type_schema)
        if p.description and not schema.description:
            schema.description = p.description
        properties[p.name] = json.loads(schema.json(exclude_none=True))
        if p.required:
            required.append(p.name)
    return {"type": "object", "properties": properties, "required": required}

Subdomains

Frequently Asked Questions

What does _openapi_params_to_json_schema() do?
_openapi_params_to_json_schema() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/openai_functions/openapi.py.
Where is _openapi_params_to_json_schema() defined?
_openapi_params_to_json_schema() is defined in libs/langchain/langchain_classic/chains/openai_functions/openapi.py at line 69.
What calls _openapi_params_to_json_schema()?
_openapi_params_to_json_schema() is called by 1 function(s): openapi_spec_to_openai_fn.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free