-
Notifications
You must be signed in to change notification settings - Fork 382
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
Add support for deepseek #534
base: main
Are you sure you want to change the base?
Add support for deepseek #534
Conversation
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.
Please see inline comments and
- Add unittests for deepseek model wrapper.
- Update doc, including tutorial and README.md
) | ||
|
||
# from agentscope.agents import DialogAgent |
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.
Remove unnecessary changes.
@@ -56,7 +56,14 @@ def log_stream_msg(msg: Msg, last: bool = True) -> None: | |||
|
|||
# Print msg to terminal | |||
formatted_str = msg.formatted_str(colored=True) | |||
|
|||
|
|||
# Debug prefix tracking |
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.
Remove debug loggings
@@ -48,3 +48,61 @@ def _verify_text_content_in_openai_message_response(response: dict) -> bool: | |||
return False | |||
|
|||
return True | |||
|
|||
|
|||
def _verify_reasoning_content_in_openai_message_response( |
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.
openai or deepseek or both?
def __init__( | ||
self, | ||
config_name: str, | ||
model_name: 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.
model_name
is a required parameter
# then the model name is deepseek-r1 and deepseek-v3 | ||
|
||
# supported_models: list[str] = [ | ||
# "deepseek-chat", |
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.
Since we don't hope developers to modify this file, it's suggested to add deepseek-r1
and deepseek-v3
into the supported models.
generate_args: Optional[dict] = None, | ||
**kwargs: Any, | ||
) -> None: | ||
"""Initalize the openai client. |
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.
Change the docstrings for deepseek.
if usage is not None: | ||
self.monitor.update_text_and_embedding_tokens( | ||
model_name=self.model_name, | ||
prompt_tokens=usage.get("prompt_tokens", 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.
What about reasoning tokens?
Add support for deepseek official api
Description
This PR adds support for the Deepseek API. Since Deepseek uses an OpenAI-compatible API, the wrapper is almost the same as the OpenAI one. The key difference lies in the yield generator, which now needs to access both the
content
andreasoning_content
fields from the response.issues
The Deepseek official URL is often unresponsive. For testing and debugging, use the Aliyun-hosted version as a fallback.
The streaming handling in logging.py causes bugs when displaying flags to indicate whether reasoning and final answer generation have started. Consider a better implementation.
Streaming content can be a bit chunky because responses arrive faster than they are consumed. A better implementation (e.g., buffering or fixed-rate throttling) is needed to handle streaming more effectively.