1
This commit is contained in:
@@ -14,12 +14,6 @@ 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',
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ export const generateContent = async (
|
|||||||
const requestOptions: any = {
|
const requestOptions: any = {
|
||||||
model: config.model,
|
model: config.model,
|
||||||
messages,
|
messages,
|
||||||
temperature: config.temperature,
|
// Clamp temperature to 1.0 max for compatibility with strict providers (NVIDIA, vLLM, etc.)
|
||||||
|
temperature: typeof config.temperature === 'number' ? Math.min(config.temperature, 1.0) : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (config.responseFormat === 'json_object') {
|
if (config.responseFormat === 'json_object') {
|
||||||
@@ -68,7 +69,7 @@ export const generateContent = async (
|
|||||||
const message = response.choices[0]?.message;
|
const message = response.choices[0]?.message;
|
||||||
const content = message?.content || '';
|
const content = message?.content || '';
|
||||||
|
|
||||||
// Check for DeepSeek native reasoning field
|
// Check for native reasoning_content field (DeepSeek/NVIDIA style)
|
||||||
const reasoningContent = (message as any)?.reasoning_content;
|
const reasoningContent = (message as any)?.reasoning_content;
|
||||||
|
|
||||||
if (reasoningContent && config.thinkingConfig?.includeThoughts) {
|
if (reasoningContent && config.thinkingConfig?.includeThoughts) {
|
||||||
@@ -108,7 +109,8 @@ export async function* generateContentStream(
|
|||||||
const requestOptions: any = {
|
const requestOptions: any = {
|
||||||
model: config.model,
|
model: config.model,
|
||||||
messages,
|
messages,
|
||||||
temperature: config.temperature,
|
// Clamp temperature to 1.0 max for compatibility with strict providers
|
||||||
|
temperature: typeof config.temperature === 'number' ? Math.min(config.temperature, 1.0) : undefined,
|
||||||
stream: true,
|
stream: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,29 +121,32 @@ export async function* generateContentStream(
|
|||||||
let currentThought = '';
|
let currentThought = '';
|
||||||
|
|
||||||
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;
|
||||||
// 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;
|
||||||
|
|
||||||
accumulatedText += delta;
|
const content = delta.content || '';
|
||||||
|
// Check for native reasoning_content field (DeepSeek/NVIDIA style)
|
||||||
|
const reasoning = delta.reasoning_content || '';
|
||||||
|
|
||||||
|
// If native reasoning field exists, emit it immediately
|
||||||
|
if (reasoning && config.thinkingConfig?.includeThoughts) {
|
||||||
|
yield { text: '', thought: reasoning };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (content) {
|
||||||
|
accumulatedText += content;
|
||||||
|
|
||||||
if (config.thinkingConfig?.includeThoughts) {
|
if (config.thinkingConfig?.includeThoughts) {
|
||||||
if (delta.includes('<thinking>')) {
|
// Fallback to tag parsing if reasoning_content wasn't provided but tags exist
|
||||||
|
if (content.includes('<thinking>')) {
|
||||||
inThinking = true;
|
inThinking = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inThinking) {
|
if (inThinking) {
|
||||||
if (delta.includes('</thinking>')) {
|
if (content.includes('</thinking>')) {
|
||||||
inThinking = false;
|
inThinking = false;
|
||||||
const parts = delta.split('</thinking>', 2);
|
const parts = content.split('</thinking>', 2);
|
||||||
currentThought += parts[0];
|
currentThought += parts[0];
|
||||||
|
|
||||||
if (currentThought.trim()) {
|
if (currentThought.trim()) {
|
||||||
@@ -153,17 +158,19 @@ export async function* generateContentStream(
|
|||||||
yield { text: parts[1], thought: '' };
|
yield { text: parts[1], thought: '' };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
currentThought += delta;
|
currentThought += content;
|
||||||
if (currentThought.length > 100) {
|
// Emit thought chunks periodically so it doesn't hang
|
||||||
|
if (currentThought.length > 50) {
|
||||||
yield { text: '', thought: currentThought };
|
yield { text: '', thought: currentThought };
|
||||||
currentThought = '';
|
currentThought = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
yield { text: delta, thought: '' };
|
yield { text: content, thought: '' };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
yield { text: delta, thought: '' };
|
yield { text: content, thought: '' };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ export const MANAGER_SYSTEM_PROMPT = `You are the "Dynamic Planning Engine". You
|
|||||||
|
|
||||||
Your job is to create SUPPLEMENTARY experts
|
Your job is to create SUPPLEMENTARY experts
|
||||||
|
|
||||||
For each expert, you must assign a specific 'temperature' (0.0 to 2.0) based on the nature of their task:
|
For each expert, you must assign a specific 'temperature' (0.0 to 1.0) based on the nature of their task:
|
||||||
|
|
||||||
* High temperature (1.0 - 2.0)
|
* High temperature (0.7 - 1.0) - For creative, brainstorming, or open-ended tasks.
|
||||||
* Low temperature (0.0 - 0.4)
|
* Low temperature (0.0 - 0.3) - For code, math, logic, or factual tasks.
|
||||||
* Medium temperature (0.4 - 1.0)`;
|
* Medium temperature (0.3 - 0.7) - For balanced analysis and general explanation.`;
|
||||||
|
|
||||||
export const MANAGER_REVIEW_SYSTEM_PROMPT = `
|
export const MANAGER_REVIEW_SYSTEM_PROMPT = `
|
||||||
You are the "Quality Assurance & Orchestration Engine".
|
You are the "Quality Assurance & Orchestration Engine".
|
||||||
|
|||||||
Reference in New Issue
Block a user