1
This commit is contained in:
@@ -14,6 +14,12 @@ export const MODELS: { value: ModelOption; label: string; desc: string; provider
|
|||||||
desc: 'Deep reasoning, complex tasks, higher intelligence.',
|
desc: 'Deep reasoning, complex tasks, higher intelligence.',
|
||||||
provider: 'google'
|
provider: 'google'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
value: 'deepseek-reasoner',
|
||||||
|
label: 'DeepSeek R1',
|
||||||
|
desc: 'State-of-the-art open reasoning model.',
|
||||||
|
provider: 'deepseek'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: 'custom',
|
value: 'custom',
|
||||||
label: 'Custom Model',
|
label: 'Custom Model',
|
||||||
|
|||||||
@@ -65,7 +65,15 @@ export const generateContent = async (
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await withRetry(() => ai.chat.completions.create(requestOptions));
|
const response = await withRetry(() => ai.chat.completions.create(requestOptions));
|
||||||
const content = response.choices[0]?.message?.content || '';
|
const message = response.choices[0]?.message;
|
||||||
|
const content = message?.content || '';
|
||||||
|
|
||||||
|
// Check for DeepSeek native reasoning field
|
||||||
|
const reasoningContent = (message as any)?.reasoning_content;
|
||||||
|
|
||||||
|
if (reasoningContent && config.thinkingConfig?.includeThoughts) {
|
||||||
|
return { text: content, thought: reasoningContent };
|
||||||
|
}
|
||||||
|
|
||||||
if (config.thinkingConfig?.includeThoughts) {
|
if (config.thinkingConfig?.includeThoughts) {
|
||||||
const { thought, text } = parseThinkingTokens(content);
|
const { thought, text } = parseThinkingTokens(content);
|
||||||
@@ -112,6 +120,13 @@ export async function* generateContentStream(
|
|||||||
|
|
||||||
for await (const chunk of (stream as any)) {
|
for await (const chunk of (stream as any)) {
|
||||||
const delta = chunk.choices[0]?.delta?.content || '';
|
const delta = chunk.choices[0]?.delta?.content || '';
|
||||||
|
// Support DeepSeek native reasoning field
|
||||||
|
const reasoningDelta = (chunk.choices[0]?.delta as any)?.reasoning_content || '';
|
||||||
|
|
||||||
|
// If we have native reasoning content, yield it immediately as thought
|
||||||
|
if (reasoningDelta) {
|
||||||
|
yield { text: '', thought: reasoningDelta };
|
||||||
|
}
|
||||||
|
|
||||||
if (!delta) continue;
|
if (!delta) continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user