mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
DeepSeek: Add tool calling for -chat model
This commit is contained in:
@ -1934,7 +1934,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter,groq">
|
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter,groq,deepseek">
|
||||||
<label for="openai_function_calling" class="checkbox_label flexWrap widthFreeExpand">
|
<label for="openai_function_calling" class="checkbox_label flexWrap widthFreeExpand">
|
||||||
<input id="openai_function_calling" type="checkbox" />
|
<input id="openai_function_calling" type="checkbox" />
|
||||||
<span data-i18n="Enable function calling">Enable function calling</span>
|
<span data-i18n="Enable function calling">Enable function calling</span>
|
||||||
|
@ -1917,6 +1917,10 @@ async function sendOpenAIRequest(type, messages, signal) {
|
|||||||
'reasoning_effort': String(oai_settings.reasoning_effort),
|
'reasoning_effort': String(oai_settings.reasoning_effort),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
|
||||||
|
await ToolManager.registerFunctionToolsOpenAI(generate_data);
|
||||||
|
}
|
||||||
|
|
||||||
// Empty array will produce a validation error
|
// Empty array will produce a validation error
|
||||||
if (!Array.isArray(generate_data.stop) || !generate_data.stop.length) {
|
if (!Array.isArray(generate_data.stop) || !generate_data.stop.length) {
|
||||||
delete generate_data.stop;
|
delete generate_data.stop;
|
||||||
@ -2040,6 +2044,8 @@ async function sendOpenAIRequest(type, messages, signal) {
|
|||||||
delete generate_data.top_logprobs;
|
delete generate_data.top_logprobs;
|
||||||
delete generate_data.logprobs;
|
delete generate_data.logprobs;
|
||||||
delete generate_data.logit_bias;
|
delete generate_data.logit_bias;
|
||||||
|
delete generate_data.tools;
|
||||||
|
delete generate_data.tool_choice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2047,10 +2053,6 @@ async function sendOpenAIRequest(type, messages, signal) {
|
|||||||
generate_data['seed'] = oai_settings.seed;
|
generate_data['seed'] = oai_settings.seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
|
|
||||||
await ToolManager.registerFunctionToolsOpenAI(generate_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isOAI && (oai_settings.openai_model.startsWith('o1') || oai_settings.openai_model.startsWith('o3'))) {
|
if (isOAI && (oai_settings.openai_model.startsWith('o1') || oai_settings.openai_model.startsWith('o3'))) {
|
||||||
generate_data.messages.forEach((msg) => {
|
generate_data.messages.forEach((msg) => {
|
||||||
if (msg.role === 'system') {
|
if (msg.role === 'system') {
|
||||||
|
@ -563,6 +563,7 @@ export class ToolManager {
|
|||||||
chat_completion_sources.OPENROUTER,
|
chat_completion_sources.OPENROUTER,
|
||||||
chat_completion_sources.GROQ,
|
chat_completion_sources.GROQ,
|
||||||
chat_completion_sources.COHERE,
|
chat_completion_sources.COHERE,
|
||||||
|
chat_completion_sources.DEEPSEEK,
|
||||||
];
|
];
|
||||||
return supportedSources.includes(oai_settings.chat_completion_source);
|
return supportedSources.includes(oai_settings.chat_completion_source);
|
||||||
}
|
}
|
||||||
|
@ -679,6 +679,11 @@ async function sendDeepSeekRequest(request, response) {
|
|||||||
bodyParams['logprobs'] = true;
|
bodyParams['logprobs'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
|
||||||
|
bodyParams['tools'] = request.body.tools;
|
||||||
|
bodyParams['tool_choice'] = request.body.tool_choice;
|
||||||
|
}
|
||||||
|
|
||||||
const postProcessType = String(request.body.model).endsWith('-reasoner') ? 'deepseek-reasoner' : 'deepseek';
|
const postProcessType = String(request.body.model).endsWith('-reasoner') ? 'deepseek-reasoner' : 'deepseek';
|
||||||
const processedMessages = postProcessPrompt(request.body.messages, postProcessType, getPromptNames(request));
|
const processedMessages = postProcessPrompt(request.body.messages, postProcessType, getPromptNames(request));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user