How to send headers in API chain chain = OpenAPIEndpointChain.from_api_operation( operation, llm, requests=Requests(), verbose=True, return_intermediate_steps=True, # Return request and response text ) #17941
Replies: 2 comments
-
🤖 Hey there, @Nidhipriya8! Great to see you back in the LangChain realm. Hope this challenge turns into a triumph with a bit of teamwork! Based on the context provided, it seems like you're trying to pass headers to the API request using the From the issues I found in the LangChain repository, it seems that other users have faced similar problems. Here are some of the relevant issues:
In the third issue, a user suggested a solution where they set the headers directly on the A more appropriate way to handle this would be to modify the def deserialize_json_input(self, serialized_args: str) -> dict:
"""Use the serialized typescript dictionary.
Resolve the path, query params dict, and optional requestBody dict.
"""
args: dict = json.loads(serialized_args)
path = self._construct_path(args)
body_params = self._extract_body_params(args)
query_params = self._extract_query_params(args)
headers = args.get('headers', {}) # Extract headers from the arguments
return {
"url": path,
"data": body_params,
"params": query_params,
"headers": headers, # Include headers in the request arguments
} In this modification, we're assuming that the headers are passed in the serialized arguments under the key 'headers'. If the headers are not provided, an empty dictionary is used as a default. Please note that this modification will affect all API calls made using this chain. If you need to pass different headers for different API calls, you should ensure that the correct headers are included in the serialized arguments for each call. I hope this helps! If you have any other questions, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
@Nidhipriya8 How did you solve this problem? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am unable to pass headers successfully in the request.
System Info
Mac Os
python versionn3.11
the output of python -m langchain_core.sys_info
/Users/nidhipriya/anaconda3/bin/python: Error while finding module specification for 'langchain_core.sys_info' (ModuleNotFoundError: No module named 'langchain_core')
(base) nidhipriya@NOI-C02D64QFMD6N MigrationCheck % python3 -m langchain_core.sys_info
/usr/local/opt/python@3.11/bin/python3.11: Error while finding module specification for 'langchain_core.sys_info' (ModuleNotFoundError: No module named 'langchain_core')
Beta Was this translation helpful? Give feedback.
All reactions