The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]: Adding HEADER to the list of supported locations (#21946)
Bruno Alvisio5eabe904940c
diff --git a/libs/community/langchain_community/tools/openapi/utils/api_models.py b/libs/community/langchain_community/tools/openapi/utils/api_models.pyindex 968f85dfa6..7b02655f4c 100644--- a/libs/community/langchain_community/tools/openapi/utils/api_models.py+++ b/libs/community/langchain_community/tools/openapi/utils/api_models.py@@ -55,6 +55,7 @@ class APIPropertyLocation(Enum):_SUPPORTED_MEDIA_TYPES = ("application/json",)SUPPORTED_LOCATIONS = {+ APIPropertyLocation.HEADER,APIPropertyLocation.QUERY,APIPropertyLocation.PATH,}diff --git a/libs/community/tests/unit_tests/data/openapi_specs/openapi_spec_header_param.json b/libs/community/tests/unit_tests/data/openapi_specs/openapi_spec_header_param.jsonnew file mode 100644index 0000000000..ff38939c0a--- /dev/null+++ b/libs/community/tests/unit_tests/data/openapi_specs/openapi_spec_header_param.json@@ -0,0 +1,34 @@+{+ "openapi": "3.0.0",+ "info": {+ "version": "1.0.0",+ "title": "Swagger Petstore",+ "license": {+ "name": "MIT"+ }+ },+ "servers": [+ {+ "url": "http://petstore.swagger.io/v1"+ }+ ],+ "paths": {+ "/pets": {+ "get": {+ "summary": "Info for a specific pet",+ "operationId": "showPetById",+ "parameters": [+ {+ "name": "header_param",+ "in": "header",+ "required": true,+ "description": "A header param",+ "schema": {+ "type": "string"+ }+ }+ ]+ }+ }+ }+ }\ No newline at end of filediff --git a/libs/community/tests/unit_tests/utilities/test_openapi.py b/libs/community/tests/unit_tests/utilities/test_openapi.pynew file mode 100644index 0000000000..e7e8b74557--- /dev/null+++ b/libs/community/tests/unit_tests/utilities/test_openapi.py@@ -0,0 +1,44 @@+from pathlib import Path++import pytest+from langchain.chains.openai_functions.openapi import openapi_spec_to_openai_fn++from langchain_community.utilities.openapi import ( # noqa: E402 # ignore: community-import+ OpenAPISpec,+)++EXPECTED_OPENAI_FUNCTIONS_HEADER_PARAM = [+ {+ "name": "showPetById",+ "description": "Info for a specific pet",+ "parameters": {+ "type": "object",+ "properties": {+ "headers": {+ "type": "object",+ "properties": {+ "header_param": {+ "type": "string",+ "description": "A header param",+ }+ },+ "required": ["header_param"],+ }+ },+ },+ }+]++[email protected]("openapi_pydantic")+def test_header_param() -> None:+ spec = OpenAPISpec.from_file(+ Path(__file__).parent.parent+ / "data"+ / "openapi_specs"+ / "openapi_spec_header_param.json",+ )++ openai_functions, _ = openapi_spec_to_openai_fn(spec)++ assert openai_functions == EXPECTED_OPENAI_FUNCTIONS_HEADER_PARAM