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

Add DeepSeek integration for Zed Assistant #23551

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Cupnfish
Copy link
Contributor

@Cupnfish Cupnfish commented Jan 23, 2025

Release Notes:

  • Added support for DeepSeek as a new language model provider in Zed Assistant
  • Implemented streaming API support for real-time responses from DeepSeek models.
  • Added a configuration UI for DeepSeek API key management and settings.
  • Updated documentation with detailed setup instructions for DeepSeek integration.
  • Added DeepSeek-specific icons and model definitions for seamless integration into the Zed UI.
  • Integrated DeepSeek into the language model registry, making it available alongside other providers like OpenAI and Anthropic.

- Add DeepSeek as a new language model provider
- Implement DeepSeek API client with streaming support
- Add DeepSeek configuration UI and settings
- Update documentation with DeepSeek setup instructions
- Add DeepSeek icon and model definitions
- Integrate DeepSeek into language model registry
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 23, 2025
@maxdeviant maxdeviant changed the title feat: add DeepSeek integration for Zed Assistant Add DeepSeek integration for Zed Assistant Jan 23, 2025
@maxdeviant maxdeviant self-assigned this Jan 23, 2025
@notpeter

This comment was marked as resolved.

@maxdeviant

This comment was marked as resolved.

- Add message merging to fix '400 Bad Request' error for Reasoner model
- Address error: 'deepseek-reasoner does not support successive user or assistant messages'
- Merge consecutive messages of same role before sending to API
- Handle User, System, Assistant and Tool message types
- Preserve tool_calls in merged assistant messages
- Add comprehensive test coverage for message merging logic
- Optimize string concatenation with reserve and push_str
- Make Model::id const for better performance

Fixes ERROR assistant_context_editor] Failed to connect to DeepSeek API: 400 Bad Request {'error':{'message':'deepseek-reasoner does not support successive user or assistant messages (messages[0] and messages[1] in your input). You should interleave the user/assistant messages in the message sequence.','type':'invalid_request_error','param':null,'code':'invalid_request_error'}}
@Cupnfish
Copy link
Contributor Author

deepseek-ai/DeepSeek-R1#21

Fixed issues:

ERROR assistant_context_editor] Failed to connect to DeepSeek API: 400 Bad Request {"error":{"message":"deepseek-reasoner does not support successive user or assistant messages (messages[0] and messages[1] in your input). You should interleave the user/assistant messages in the message sequence.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

However, I'm not sure if the chosen method is the most appropriate. Welcome to discuss

…ek API

- Removed custom DeepSeekError struct and simplified error handling in the `complete` function.
- Refactored `merge_consecutive_messages` to use a more straightforward iteration approach.
- Introduced helper functions `merge_messages` and `can_merge` to improve readability.
- Updated tests to reflect changes in message merging behavior.
- Added `Custom` variant to `deepseek::Model` enum to support custom models
- Updated `id()`, `display_name()`, `max_token_count()`, and `max_output_tokens()` methods to handle custom models
- Modified `provided_models()` in DeepSeek provider to include custom models from settings
@Cupnfish
Copy link
Contributor Author

I think the current implementation is ready for review. The only drawback is that the thinking process of r1 is not displayed on the UI. I believe this feature can be considered in a follow-up PR. However, I'm not very familiar with GPUI, so I hope someone can implement it, as r1's thought process is transparent, and displaying it would be very helpful for subsequent operations.

… unused complete function

- Removed the `complete` function and its associated tests from `deepseek.rs`
- Moved message merging logic from `deepseek.rs` to `request.rs`'s `into_deepseek` method
- Simplified `stream_completion` by removing redundant message merging
- Updated message merging to handle both user and assistant messages in one pass
- Maintained existing functionality while improving code organization
@Cupnfish Cupnfish mentioned this pull request Jan 25, 2025
1 task
@shishkin
Copy link

@Cupnfish you mention that this PR is "enabling users to utilize DeepSeek models for code completion". Which part of the changes deals with code completions in particular? I can't find anything implementing inline_completion::InlineCompletionProvider like what Copilot provider does.

@Cupnfish
Copy link
Contributor Author

Cupnfish commented Jan 25, 2025

@shishkin Sorry for the misunderstanding, deepseek does indeed support code completion, but it was not implemented at the PR. I have already revised the release notes. If anyone is interested in implementing this feature, they can refer to this document:

https://api-docs.deepseek.com/guides/fim_completion
https://api-docs.deepseek.com/guides/chat_prefix_completion

@akilcelen
Copy link

hi,
Deepseek Gets cut off mid-work. Why is that? I can never complete my codes because of that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants