Deepseek
Supporting deepseek-reasoner¶
Implementation¶
- Currently,
deepseek-chatworks as expected butdeepseek-reasonerdoesn't. It fails with this error:Let's figure it out why.Error: stream error: POST "https://api.deepseek.com/chat/completions": 400 Bad Request {"message":"Missing `reasoning_content` field in the assistant message at message index 1. For more information, please refer to https://api-docs.deepseek.com/guides/thinking_mode#tool- calls","type":"invalid_request_error","param":null,"code":"invalid_request_error"} - I think we need to provide
reasoning_contentfield fordeepseek-reasonermodel. Since Genkit currently doesn't support it, we need to add support for it using some other mechanism. Suggest some possible approaches. - Does openai-go support reasoning_content already? Check the library directly. It is an indirect dependency.
- We should rather have an openai client implemented that implements the LLMClient interface. Update the plan.
- Currently we will only focus on DeepSeek. We don't want to migrate other OpenAI compatible providers. Update the plan.
- Why do we need Tool-related fields in Message struct? Are they really needed? Is
ReasoningContentnot enough? - Ok for now, let's focus on solving the error for DeepSeek. We can revisit AppState.messages later. Update the plan.
- Don't use "deepSeek" names in variables. In future we might move other providers.
- Why do we need internal wire models? Can we not use already supported models from openai-go sdk? Explore it and figure out.
- The messages for deepseek-reasoner are not streaming to the UI. Figure out why and fix it.
- Between reasoning_content and LLM messages, there should be a new line to separate them. Implement it.
- What is the purpose of alreadyStreamed variable? Explain it. Also add a concise comment in the code for it.
- Currently, the
StreamChatfunction in openai.go is long. There are some duplication in code too. Refactor it. - Now, we want to show reasoning text differently from LLM messages. How can we implement it aligning with the existing code? Suggest the most appropriate approach and create a todo list.
- Okay let's implement.
UI Improvements¶
- Every tool call is showing the same loading text. Let's change the behaviour.
- No need, just reuse the existing loadingTexts.
- Review the loadingTexts. They are too vanilla. Change them to some madeup words that give the vibe of working on something.
- We show a loding spinner. Let's change its behaviour from a fixed one to a random one.