mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Function calling for Mistral
This commit is contained in:
@ -1739,7 +1739,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block" data-source="openai,cohere,custom">
|
<div class="range-block" data-source="openai,cohere,mistralai,custom">
|
||||||
<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>
|
||||||
|
@ -1968,7 +1968,7 @@ async function registerFunctionTools(type, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkFunctionToolCalls(data) {
|
async function checkFunctionToolCalls(data) {
|
||||||
if ([chat_completion_sources.OPENAI, chat_completion_sources.CUSTOM].includes(oai_settings.chat_completion_source)) {
|
if ([chat_completion_sources.OPENAI, chat_completion_sources.CUSTOM, chat_completion_sources.MISTRALAI].includes(oai_settings.chat_completion_source)) {
|
||||||
if (!Array.isArray(data?.choices)) {
|
if (!Array.isArray(data?.choices)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1987,7 +1987,7 @@ async function checkFunctionToolCalls(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const toolCall of toolCalls) {
|
for (const toolCall of toolCalls) {
|
||||||
if (toolCall.type !== 'function') {
|
if (typeof toolCall.function !== 'object') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2027,6 +2027,7 @@ export function isFunctionCallingSupported() {
|
|||||||
chat_completion_sources.OPENAI,
|
chat_completion_sources.OPENAI,
|
||||||
chat_completion_sources.COHERE,
|
chat_completion_sources.COHERE,
|
||||||
chat_completion_sources.CUSTOM,
|
chat_completion_sources.CUSTOM,
|
||||||
|
chat_completion_sources.MISTRALAI,
|
||||||
];
|
];
|
||||||
return supportedSources.includes(oai_settings.chat_completion_source);
|
return supportedSources.includes(oai_settings.chat_completion_source);
|
||||||
}
|
}
|
||||||
|
@ -486,6 +486,11 @@ async function sendMistralAIRequest(request, response) {
|
|||||||
'random_seed': request.body.seed === -1 ? undefined : request.body.seed,
|
'random_seed': request.body.seed === -1 ? undefined : request.body.seed,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
|
||||||
|
requestBody['tools'] = request.body.tools;
|
||||||
|
requestBody['tool_choice'] = request.body.tool_choice === 'required' ? 'any' : 'auto';
|
||||||
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
Reference in New Issue
Block a user