langchain/tests/integration_tests/chains/openai_functions/test_openapi.py
Ismail Pelaseyed fcb3a64799
Add support for passing headers and search params to openai openapi chain (#6782)
- 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>
2023-06-27 09:09:03 -07:00

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)