From ce094a1ad44612900a09bcee8442cf9ff7b5f6db Mon Sep 17 00:00:00 2001 From: Alex-Karmazin Date: Sun, 23 Jun 2024 22:52:50 +0300 Subject: [PATCH] Fixing problem passing api key in options and dirrectly as parameter. --- just_agents/streaming/openai_streaming.py | 2 ++ just_agents/streaming/qwen_streaming.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/just_agents/streaming/openai_streaming.py b/just_agents/streaming/openai_streaming.py index 25a0faf..9cf7c99 100644 --- a/just_agents/streaming/openai_streaming.py +++ b/just_agents/streaming/openai_streaming.py @@ -15,6 +15,8 @@ async def resp_async_generator(self, memory: Memory, key_getter: Callable[[], str] = None ) -> AsyncGenerator[str, None]: api_key = key_getter() if key_getter is not None else None + if api_key is None: + api_key = options.pop("api_key", None) response: ModelResponse = completion(messages=memory.messages, stream=True, api_key=api_key, **options) parser: Optional[FunctionParser] = None tool_messages: list[Message] = [] diff --git a/just_agents/streaming/qwen_streaming.py b/just_agents/streaming/qwen_streaming.py index 5010bea..a800847 100644 --- a/just_agents/streaming/qwen_streaming.py +++ b/just_agents/streaming/qwen_streaming.py @@ -95,6 +95,9 @@ async def resp_async_generator(self, memory: Memory, options: Dict, available_to :return: """ api_key = key_getter() if key_getter is not None else None + if api_key is None: + api_key = options.pop("api_key", None) + response: ModelResponse = completion(messages=memory.messages, stream=True, api_key=api_key, **options) parser: QwenFunctionParser = QwenFunctionParser() deltas: list[str] = []