Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Together AI Client #2919

Merged
merged 22 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a79519d
First pass together.ai client class
marklysze Jun 11, 2024
e86738d
Config handling, models and cost
marklysze Jun 12, 2024
62ad221
Added tests, moved param management to create function
marklysze Jun 13, 2024
5eb4abb
Merge remote-tracking branch 'origin/main' into togetherai_client
marklysze Jun 14, 2024
5e13490
Tests, parameter, validation, logging updates
marklysze Jun 14, 2024
75b5650
Added use of client_utils PR 2949
marklysze Jun 15, 2024
476c08d
Merge remote-tracking branch 'origin/main' into togetherai_client
marklysze Jun 15, 2024
3246e8b
Updated to return OAI response
marklysze Jun 16, 2024
df8f95c
Notebook example
marklysze Jun 17, 2024
8eb7ff4
Merge remote-tracking branch 'origin/main' into togetherai_client
marklysze Jun 19, 2024
1c13831
Improved function calling, updated tests, updated notebook with Chess…
marklysze Jun 19, 2024
fa083bb
Merge remote-tracking branch 'origin/main' into togetherai_client
marklysze Jun 19, 2024
e1eb584
Merge remote-tracking branch 'origin/main' into togetherai_client
marklysze Jun 19, 2024
7666e94
Tidied up together client class, better parameter handling, simpler e…
marklysze Jun 19, 2024
9740d00
Update of documentation notebook, replacement of old version
marklysze Jun 19, 2024
4465ecb
Merge remote-tracking branch 'origin/main' into togetherai_client
marklysze Jun 19, 2024
78394c3
Fix of messages parameter for hide_tools function call
marklysze Jun 19, 2024
f3418d7
Update autogen/oai/together.py
marklysze Jun 20, 2024
dc4de34
Update together.py to fix text
marklysze Jun 20, 2024
1ac4a7a
Merge branch 'main' into togetherai_client
yiranwu0 Jun 21, 2024
c82ba87
Merge remote-tracking branch 'origin/main' into togetherai_client
marklysze Jun 21, 2024
e56c0c7
Merge branch 'main' into togetherai_client
sonichi Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/contrib-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,43 @@ jobs:
with:
file: ./coverage.xml
flags: unittests

TogetherTest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
python-version: ["3.9", "3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
python-version: "3.9"
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install packages and dependencies for all tests
run: |
python -m pip install --upgrade pip wheel
pip install pytest-cov>=5
- name: Install packages and dependencies for Together
run: |
pip install -e .[together,test]
- name: Set AUTOGEN_USE_DOCKER based on OS
shell: bash
run: |
if [[ ${{ matrix.os }} != ubuntu-latest ]]; then
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
fi
- name: Coverage
run: |
pytest test/oai/test_together.py --skip-openai
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
3 changes: 2 additions & 1 deletion autogen/logger/file_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from autogen import Agent, ConversableAgent, OpenAIWrapper
from autogen.oai.anthropic import AnthropicClient
from autogen.oai.gemini import GeminiClient
from autogen.oai.together import TogetherClient

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -202,7 +203,7 @@ def log_new_wrapper(

def log_new_client(
self,
client: AzureOpenAI | OpenAI | GeminiClient | AnthropicClient,
client: AzureOpenAI | OpenAI | GeminiClient | AnthropicClient | TogetherClient,
wrapper: OpenAIWrapper,
init_args: Dict[str, Any],
) -> None:
Expand Down
3 changes: 2 additions & 1 deletion autogen/logger/sqlite_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from autogen import Agent, ConversableAgent, OpenAIWrapper
from autogen.oai.anthropic import AnthropicClient
from autogen.oai.gemini import GeminiClient
from autogen.oai.together import TogetherClient

logger = logging.getLogger(__name__)
lock = threading.Lock()
Expand Down Expand Up @@ -389,7 +390,7 @@ def log_function_use(self, source: Union[str, Agent], function: F, args: Dict[st

def log_new_client(
self,
client: Union[AzureOpenAI, OpenAI, GeminiClient, AnthropicClient],
client: Union[AzureOpenAI, OpenAI, GeminiClient, AnthropicClient, TogetherClient],
wrapper: OpenAIWrapper,
init_args: Dict[str, Any],
) -> None:
Expand Down
11 changes: 11 additions & 0 deletions autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
except ImportError as e:
anthropic_import_exception = e

try:
from autogen.oai.together import TogetherClient

together_import_exception: Optional[ImportError] = None
except ImportError as e:
together_import_exception = e

logger = logging.getLogger(__name__)
if not logger.handlers:
# Add the console handler.
Expand Down Expand Up @@ -461,6 +468,10 @@ def _register_default_client(self, config: Dict[str, Any], openai_config: Dict[s
raise ImportError("Please install `anthropic` to use Anthropic API.")
client = AnthropicClient(**openai_config)
self._clients.append(client)
elif api_type is not None and api_type.startswith("together"):
if together_import_exception:
raise ImportError("Please install `together` to use the Together.AI API.")
self._clients.append(TogetherClient(**config))
else:
client = OpenAI(**openai_config)
self._clients.append(OpenAIClient(client))
Expand Down
Loading
Loading