Skip to content

Commit

Permalink
Fixing problem passing api key in options and dirrectly as parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Karmazin committed Jun 23, 2024
1 parent b8bfda8 commit ce094a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions just_agents/streaming/openai_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down
3 changes: 3 additions & 0 deletions just_agents/streaming/qwen_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down

0 comments on commit ce094a1

Please sign in to comment.