mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
fcb3a64799
- Description: add support for passing headers and search params to OpenAI OpenAPI chains. - Issue: n/a - Dependencies: n/a - Tag maintainer: @hwchase17 - Twitter handle: @pelaseyed --------- Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
26 lines
821 B
Python
26 lines
821 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
from langchain.chains.openai_functions.openapi import get_openapi_chain
|
|
|
|
|
|
def test_openai_opeanapi() -> None:
|
|
chain = get_openapi_chain(
|
|
"https://www.klarna.com/us/shopping/public/openai/v0/api-docs/"
|
|
)
|
|
output = chain.run("What are some options for a men's large blue button down shirt")
|
|
|
|
assert isinstance(output, dict)
|
|
|
|
|
|
def test_openai_opeanapi_headers() -> None:
|
|
BRANDFETCH_API_KEY = os.environ.get("BRANDFETCH_API_KEY")
|
|
headers = {"Authorization": f"Bearer {BRANDFETCH_API_KEY}"}
|
|
file_path = str(
|
|
Path(__file__).parents[2] / "examples/brandfetch-brandfetch-2.0.0-resolved.json"
|
|
)
|
|
chain = get_openapi_chain(file_path, headers=headers)
|
|
output = chain.run("I want to know about nike.comgg")
|
|
|
|
assert isinstance(output, str)
|