From fa05d1991e7d15a3410270071e2d04fcc92dd61b Mon Sep 17 00:00:00 2001 From: Nick Bobrowski <39348559+bonk1t@users.noreply.github.com> Date: Sat, 30 Nov 2024 21:37:38 +0000 Subject: [PATCH 1/2] Minor type hint fix --- agency_swarm/agency/agency.py | 7 ++++--- agency_swarm/threads/thread.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/agency_swarm/agency/agency.py b/agency_swarm/agency/agency.py index 743739bf..2516101c 100644 --- a/agency_swarm/agency/agency.py +++ b/agency_swarm/agency/agency.py @@ -11,6 +11,7 @@ Dict, List, Literal, + Optional, Type, TypedDict, TypeVar, @@ -218,7 +219,7 @@ def get_completion( def get_completion_stream( self, message: str, - event_handler: type(AgencyEventHandler), + event_handler: Optional[Type[AgencyEventHandler]] = None, message_files: List[str] = None, recipient_agent: Agent = None, additional_instructions: str = None, @@ -231,7 +232,7 @@ def get_completion_stream( Parameters: message (str): The message for which completion is to be retrieved. - event_handler (type(AgencyEventHandler)): The event handler class to handle the completion stream. https://github.com/openai/openai-python/blob/main/helpers.md + event_handler (Type[AgencyEventHandler], optional): The event handler class to handle the completion stream. https://github.com/openai/openai-python/blob/main/helpers.md Defaults to None. message_files (list, optional): A list of file ids to be sent as attachments with the message. When using this parameter, files will be assigned both to file_search and code_interpreter tools if available. It is recommended to assign files to the most sutiable tool manually, using the attachments parameter. Defaults to None. recipient_agent (Agent, optional): The agent to which the message should be sent. Defaults to the first agent in the agency chart. additional_instructions (str, optional): Additional instructions to be sent with the message. Defaults to None. @@ -280,7 +281,7 @@ def get_completion_parse( Parameters: message (str): The message for which completion is to be retrieved. - response_format (type(BaseModel)): The response format to use for the completion. + response_format (Type[BaseModel]): The response format to use for the completion. message_files (list, optional): A list of file ids to be sent as attachments with the message. When using this parameter, files will be assigned both to file_search and code_interpreter tools if available. It is recommended to assign files to the most sutiable tool manually, using the attachments parameter. Defaults to None. recipient_agent (Agent, optional): The agent to which the message should be sent. Defaults to the first agent in the agency chart. additional_instructions (str, optional): Additional instructions to be sent with the message. Defaults to None. diff --git a/agency_swarm/threads/thread.py b/agency_swarm/threads/thread.py index e372df26..252d9fbe 100644 --- a/agency_swarm/threads/thread.py +++ b/agency_swarm/threads/thread.py @@ -5,7 +5,7 @@ import re import time from concurrent.futures import ThreadPoolExecutor, as_completed -from typing import List, Optional, Union +from typing import List, Optional, Type, Union from openai import APIError, BadRequestError from openai.types.beta import AssistantToolChoice @@ -80,7 +80,7 @@ def init_thread(self): def get_completion_stream( self, message: Union[str, List[dict], None], - event_handler: type(AgencyEventHandler), + event_handler: Optional[Type[AgencyEventHandler]] = None, message_files: List[str] = None, attachments: Optional[List[Attachment]] = None, recipient_agent: Agent = None, @@ -107,7 +107,7 @@ def get_completion( attachments: Optional[List[dict]] = None, recipient_agent: Union[Agent, None] = None, additional_instructions: str = None, - event_handler: type(AgencyEventHandler) = None, + event_handler: Optional[Type[AgencyEventHandler]] = None, tool_choice: AssistantToolChoice = None, yield_messages: bool = False, response_format: Optional[dict] = None, From a95a9dc3ddd17feb6bd3625f60682512ce5bfb0e Mon Sep 17 00:00:00 2001 From: Nick Bobrowski <39348559+bonk1t@users.noreply.github.com> Date: Sun, 1 Dec 2024 22:38:04 +0000 Subject: [PATCH 2/2] Improve test.yml Workflow --- .github/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a95f89b..187f55b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,12 @@ name: Python Unittest -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: test: