mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 11:39:18 +00:00
openapi_openai docstring (#6661)
This commit is contained in:
@@ -20,18 +20,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": null,
|
||||||
"id": "08e19b64",
|
"id": "08e19b64",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stderr",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain.chains.openai_functions.openapi import get_openapi_chain\n",
|
"from langchain.chains.openai_functions.openapi import get_openapi_chain\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -103,19 +95,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 6,
|
"execution_count": null,
|
||||||
"id": "bf6cd695",
|
"id": "bf6cd695",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stderr",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.\n",
|
|
||||||
"Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"chain = get_openapi_chain(\"https://api.speak.com/openapi.yaml\")"
|
"chain = get_openapi_chain(\"https://api.speak.com/openapi.yaml\")"
|
||||||
]
|
]
|
||||||
@@ -152,18 +135,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 8,
|
"execution_count": null,
|
||||||
"id": "a9198f62",
|
"id": "a9198f62",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stderr",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Attempting to load an OpenAPI 3.0.0 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"chain = get_openapi_chain(\"https://gist.githubusercontent.com/roaldnefs/053e505b2b7a807290908fe9aa3e1f00/raw/0a212622ebfef501163f91e23803552411ed00e4/openapi.yaml\")"
|
"chain = get_openapi_chain(\"https://gist.githubusercontent.com/roaldnefs/053e505b2b7a807290908fe9aa3e1f00/raw/0a212622ebfef501163f91e23803552411ed00e4/openapi.yaml\")"
|
||||||
]
|
]
|
||||||
|
@@ -207,6 +207,15 @@ def get_openapi_chain(
|
|||||||
prompt: Optional[BasePromptTemplate] = None,
|
prompt: Optional[BasePromptTemplate] = None,
|
||||||
request_chain: Optional[Chain] = None,
|
request_chain: Optional[Chain] = None,
|
||||||
) -> SequentialChain:
|
) -> SequentialChain:
|
||||||
|
"""Create a chain for querying an API from a OpenAPI spec.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
spec: OpenAPISpec or url/file/text string corresponding to one.
|
||||||
|
llm: language model, should be an OpenAI function-calling model, e.g.
|
||||||
|
`ChatOpenAI(model="gpt-3.5-turbo-0613")`.
|
||||||
|
prompt: Main prompt template to use.
|
||||||
|
request_chain: Chain for taking the functions output and executing the request.
|
||||||
|
"""
|
||||||
if isinstance(spec, str):
|
if isinstance(spec, str):
|
||||||
for conversion in (
|
for conversion in (
|
||||||
OpenAPISpec.from_url,
|
OpenAPISpec.from_url,
|
||||||
|
Reference in New Issue
Block a user