-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
feat: add tencent hunyuan api #1359
base: main
Are you sure you want to change the base?
Conversation
Amazing work! I have reviewed it and provided some potential improvement suggestions. |
metagpt/configs/llm_config.py
Outdated
@@ -59,6 +60,10 @@ class LLMConfig(YamlModel): | |||
secret_key: Optional[str] = None | |||
endpoint: Optional[str] = None # for self-deployed model on the cloud | |||
|
|||
# For Tencent Hunyuan | |||
secret_id: Optional[str] = None | |||
secret_key: Optional[str] = None |
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.
secret key
duplicates with line 60
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.
已处理
metagpt/utils/token_counter.py
Outdated
"hunyuan-pro": {"prompt": 0.03, "completion": 0.1}, | ||
"hunyuan-standard": {"prompt": 0.0045, "completion": 0.005}, | ||
"hunyuan-standard-256k": {"prompt": 0.015, "completion": 0.06}, | ||
"hunyuan-lite": {"prompt": 0.0, "completion": 0.0}, | ||
"hunyuan-embedding": {"prompt": 0.0007, "completion": 0.0007}, |
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.
It should be USD instead of CNY.
try:
{
"hunyuan-pro": {"prompt": "0.00420", "completion": "0.01400"},
"hunyuan-standard": {"prompt": "0.00063", "completion": "0.00070"},
"hunyuan-standard-256k": {"prompt": "0.00210", "completion": "0.00840"},
"hunyuan-lite": {"prompt": "0.0", "completion": "0.0"}
}
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.
已处理
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 #1359 +/- ##
==========================================
- Coverage 62.34% 62.25% -0.09%
==========================================
Files 283 284 +1
Lines 17371 17439 +68
==========================================
+ Hits 10830 10857 +27
- Misses 6541 6582 +41 ☔ View full report in Codecov by Sentry. |
@usamimeri 请问Codecov这个要怎样处理?
|
self.secret_key = self.config.secret_key | ||
self.endpoint = self.config.endpoint | ||
self.model = self.config.model | ||
self.region = "" |
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.
should we config this? or use self.config.region_name
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.
self.region的值为空字符串时,表示自动路由选路。建议保持现状,日后有需要再更改为可配置项。
@register_provider(LLMType.HUNYUAN) | ||
class HunYuanLLM(BaseLLM): | ||
"""参考资料 | ||
腾讯混元大模型产品概述:https://cloud.tencent.com/document/product/1729/104753 |
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.
seems hunyuan provide a compatible interface https://cloud.tencent.com/document/product/1729/111007
, should we to re-create a provider ?
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.
近期混元 API 兼容了 OpenAI 的接口规范,初步来看是更好的方案。
metagpt/provider/hunyuan_api.py
Outdated
def _make_request( | ||
self, | ||
messages: list[dict], | ||
timeout=USE_CONFIG_TIMEOUT, |
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.
timeout not used
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.
已删除
req.from_json_string(json.dumps(params)) | ||
return req | ||
|
||
async def _achat_completion(self, messages: list[dict], timeout=USE_CONFIG_TIMEOUT) -> ChatCompletionsResponse: |
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.
missing get_choice_text
implement
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.
无需重写get_choice_text()方法
腾讯混元大模型价格说明:https://cloud.tencent.com/document/product/1729/97731 | ||
""" | ||
HUNYUAN_MODEL_TOKEN_COSTS = { | ||
"hunyuan-pro": {"prompt": 0.0042, "completion": 0.014}, |
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.
missing hunyuan-turbo?
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.
已添加
Hello, could you please take another look at the code review? |
ok |
…ed timeout in hunyuan_api.py; fix price in token_counter.py
已处理 |
Can you resolve the current conflict? |
@better629 Can you do another round of code review? I'm not sure what to do with new providers, especially if they provide OpenAI compatible interfaces? |
应该没有。既然混元 API 兼容了 OpenAI 的接口规范,预期效果会更简单、兼容性更强。建议放弃本方案,@better629 改用兼容OpenAI 接口的方案。 |
@david-zlj I think you can register an LLMType to the OpenAI class and then add the document |
没看懂。能提供更多参考信息? |
Just register a type on OpenAI provider. Documentation can be pushed to https://github.com/geekan/MetaGPT-docs/ |
Features
Feature Docs
Influence
Result
测试内容:
测试输出结果:
Other
参考资料