From 56b955fc31679326004b77e4b0059fd123b951e7 Mon Sep 17 00:00:00 2001 From: kYLe Date: Fri, 23 Feb 2024 20:22:54 -0600 Subject: [PATCH] community[minor]: Add async_client for Anyscale Chat model (#18050) Add `async_client` for Anyscale Chat_model --- libs/community/langchain_community/chat_models/anyscale.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/chat_models/anyscale.py b/libs/community/langchain_community/chat_models/anyscale.py index c2916ccf71e..214b77c30fb 100644 --- a/libs/community/langchain_community/chat_models/anyscale.py +++ b/libs/community/langchain_community/chat_models/anyscale.py @@ -144,7 +144,12 @@ class ChatAnyscale(ChatOpenAI): # "default_query": values["default_query"], # "http_client": values["http_client"], } - values["client"] = openai.OpenAI(**client_params).chat.completions + if not values.get("client"): + values["client"] = openai.OpenAI(**client_params).chat.completions + if not values.get("async_client"): + values["async_client"] = openai.AsyncOpenAI( + **client_params + ).chat.completions else: values["openai_api_base"] = values["anyscale_api_base"] values["openai_api_key"] = values["anyscale_api_key"].get_secret_value()