mirror of https://github.com/hwchase17/langchain
langchain[patch]: Minor Fix: Enable Passing custom_headers for Authentication in GraphQL Agent/Tool (#16413)
- **Description:** This PR aims to enhance the `langchain` library by enabling the support for passing `custom_headers` in the `GraphQLAPIWrapper` usage within `langchain/agents/load_tools.py`. While the `GraphQLAPIWrapper` from the `langchain_community` module is inherently capable of handling `custom_headers`, its current invocation in `load_tools.py` does not facilitate this functionality. This limitation restricts the use of the `graphql` tool with databases or APIs that require token-based authentication. The absence of support for `custom_headers` in this context also leads to a lack of error messages when attempting to interact with secured GraphQL endpoints, making debugging and troubleshooting more challenging. This update modifies the `load_tools` function to correctly handle `custom_headers`, thereby allowing secure and authenticated access to GraphQL services requiring tokens. Example usage after the proposed change: ```python tools = load_tools( ["graphql"], graphql_endpoint="https://your-graphql-endpoint.com/graphql", custom_headers={"Authorization": f"Token {api_token}"}, ) ``` - **Issue:** None, - **Dependencies:** None, - **Twitter handle:** Nonepull/16568/head
parent
5c6e123757
commit
80fcc50c65
Loading…
Reference in New Issue