Home / Function/ _call() — langchain Function Reference

_call() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  3402face_2006_2c1f_b057_c685f2190047["_call()"]
  7d9cd052_b35e_d7e6_3e3f_6be2efe55548["SimpleRequestChain"]
  3402face_2006_2c1f_b057_c685f2190047 -->|defined in| 7d9cd052_b35e_d7e6_3e3f_6be2efe55548
  style 3402face_2006_2c1f_b057_c685f2190047 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/openai_functions/openapi.py lines 221–249

    def _call(
        self,
        inputs: dict[str, Any],
        run_manager: CallbackManagerForChainRun | None = None,
    ) -> dict[str, Any]:
        """Run the logic of this chain and return the output."""
        _run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
        name = inputs[self.input_key].pop("name")
        args = inputs[self.input_key].pop("arguments")
        _pretty_name = get_colored_text(name, "green")
        _pretty_args = get_colored_text(json.dumps(args, indent=2), "green")
        _text = f"Calling endpoint {_pretty_name} with arguments:\n" + _pretty_args
        _run_manager.on_text(_text)
        api_response: Response = self.request_method(name, args)
        if api_response.status_code != requests.codes.ok:
            response = (
                f"{api_response.status_code}: {api_response.reason}"
                f"\nFor {name} "
                f"Called with args: {args.get('params', '')}"
            )
        else:
            try:
                response = api_response.json()
            except JSONDecodeError:
                response = api_response.text
            except Exception:
                _logger.exception("Unexpected error parsing response as JSON")
                response = api_response.text
        return {self.output_key: response}

Subdomains

Frequently Asked Questions

What does _call() do?
_call() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/openai_functions/openapi.py.
Where is _call() defined?
_call() is defined in libs/langchain/langchain_classic/chains/openai_functions/openapi.py at line 221.

Analyze Your Own Codebase

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

Try Supermodel Free