[X] I added a very descriptive title to this issue.
[X] I searched the LangChain documentation with the integrated search.
[X] I used the GitHub search to find a similar question and didn't find it.
[X] I am sure that this is a bug in LangChain rather than my code.
[X] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
from langchain.chains.openai_functions.openapi import get_openapi_chain
chain = get_openapi_chain("http://localhost:8080/v3/api-docs", llm=llm, verbose=True)
result = chain(question)
Error Message and Stack Trace (if applicable)
No response
Description
I am using openapi functions of langchain so that LLM can invoke appropriate endpoint given OpenAPI 3.0 spec documentation. I had observed that for a POST endpoint if the request body contains a Reference to an object then the schema of the object is not sent to LLM and hence LLM creates incorrect payload.
Below is an example Open API spec where-in the POST endpoint /pet has a request body with reference to Pet
Issue is specially for 'address' and 'hobbies' attribute shown in below schema
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
No response
Description
I am using openapi functions of langchain so that LLM can invoke appropriate endpoint given OpenAPI 3.0 spec documentation. I had observed that for a POST endpoint if the request body contains a Reference to an object then the schema of the object is not sent to LLM and hence LLM creates incorrect payload.
Below is an example Open API spec where-in the POST endpoint /pet has a request body with reference to Pet Issue is specially for 'address' and 'hobbies' attribute shown in below schema
Below is the Open API 3.0 specs
{ "openapi": "3.0.1", "info": { "title": "OpenAPI definition", "version": "v0" }, "servers": [ { "url": "http://localhost:8080", "description": "Generated server url" } ], "paths": { "/pet": { "post": { "tags": [ "pet-controller" ], "operationId": "createPet", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } } }, "required": true }, "responses": { "200": { "description": "OK" } } } } }, "components": { "schemas": { "Address": { "type": "object", "properties": { "street": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" } } }, "Hobby": { "type": "object", "properties": { "name": { "type": "string" } } }, "Pet": { "type": "object", "properties": { "name": { "type": "string" }, "type": { "type": "string", "enum": [ "CAT", "DOG" ] }, "address": { "$ref": "#/components/schemas/Address" }, "hobbies": { "type": "array", "items": { "$ref": "#/components/schemas/Hobby" } } } } } } }
System Info
langchain = "0.1.9" langchain-community = "0.0.24"