mirror of
https://github.com/hwchase17/langchain.git
synced 2025-04-28 11:55:21 +00:00
Using `pyupgrade` to get all `partners` code up to 3.9 standards (mostly, fixing old `typing` imports).
18 lines
583 B
Python
18 lines
583 B
Python
import os # type: ignore[import-not-found]
|
|
|
|
from exa_py import Exa # type: ignore
|
|
from langchain_core.utils import convert_to_secret_str
|
|
|
|
|
|
def initialize_client(values: dict) -> dict:
|
|
"""Initialize the client."""
|
|
exa_api_key = values.get("exa_api_key") or os.environ.get("EXA_API_KEY") or ""
|
|
values["exa_api_key"] = convert_to_secret_str(exa_api_key)
|
|
args = {
|
|
"api_key": values["exa_api_key"].get_secret_value(),
|
|
}
|
|
if values.get("exa_base_url"):
|
|
args["base_url"] = values["exa_base_url"]
|
|
values["client"] = Exa(**args)
|
|
return values
|