From c186f18aaba6845aacfd47961189ce672c2bc19c Mon Sep 17 00:00:00 2001 From: Zeeland Date: Thu, 4 May 2023 09:49:47 +0800 Subject: [PATCH] fix: incorrect data type when construct_path in chain (#4031) A incorrect data type error happened when executing _construct_path in `chain.py` as follows: ```python Error with message replace() argument 2 must be str, not int ``` The path is always a string. But the result of `args.pop(param, "")` is undefined. --- langchain/chains/api/openapi/chain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/chains/api/openapi/chain.py b/langchain/chains/api/openapi/chain.py index 57e9ee5f..039770f7 100644 --- a/langchain/chains/api/openapi/chain.py +++ b/langchain/chains/api/openapi/chain.py @@ -61,7 +61,7 @@ class OpenAPIEndpointChain(Chain, BaseModel): """Construct the path from the deserialized input.""" path = self.api_operation.base_url + self.api_operation.path for param in self.param_mapping.path_params: - path = path.replace(f"{{{param}}}", args.pop(param, "")) + path = path.replace(f"{{{param}}}", str(args.pop(param, ""))) return path def _extract_query_params(self, args: Dict[str, str]) -> Dict[str, str]: