-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Adding Together API to the providers #1474
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
Adding Together API to the providers #1474
Conversation
|
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1474 +/- ##
==========================================
- Coverage 62.59% 62.31% -0.28%
==========================================
Files 287 288 +1
Lines 17589 17697 +108
==========================================
+ Hits 11009 11028 +19
- Misses 6580 6669 +89 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # @File : __init__.py | ||
|
|
||
| from metagpt import _compat as _ # noqa: F401 | ||
| from metagpt.provider.google_gemini_api import GeminiLLM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these codes are already in metagpt/provider/__init__.py
| from metagpt.const import LLM_API_TIMEOUT | ||
| from metagpt.utils.yaml_model import YamlModel | ||
|
|
||
| from metagpt.const import METAGPT_ROOT, CONFIG_ROOT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pre-commit to format code
| raise ValueError(f"Please set your API key in {repo_config_path}") | ||
| else: | ||
| raise ValueError("Please set your API key in config2.yaml") | ||
| raise ValueError(f"Please set your API key in config2.yaml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add f?
| @@ -0,0 +1,126 @@ | |||
| import asyncio | |||
| from typing import Optional, Union, AsyncGenerator | |||
| from together import Together | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't add together version in requirments.txt
| chunk_message = chunk.choices[0].delta.content | ||
| if chunk_message: | ||
| current_sentence += chunk_message | ||
| if chunk_message.endswith(('.', '!', '?', '\n')): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why deal with there special chars?
| if chunk_message.endswith(('.', '!', '?', '\n')): | ||
| collected_messages.append(current_sentence) | ||
| yield current_sentence | ||
| print(current_sentence, end='', flush=True) # Print each sentence as it's completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use log_llm_stream instead of print
| from metagpt.utils.exceptions import handle_exception | ||
|
|
||
| @register_provider(LLMType.TOGETHER) | ||
| class TogetherLLM(BaseLLM): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that together has openai api compatibility inferface https://docs.together.ai/docs/openai-api-compatibility. So it seems that no need to create a new provider here.
|
We know that its api is compatible with the openai api, so in theory no new class is needed. But if I'm wrong, reopen it. |

We make it possible for users of MetaGPT to use their together api and get access to the agentic features offered by MetaGPT.