mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-04-22 14:47:21 +02:00
Function calling for Groq
This commit is contained in:
parent
7d983adc6e
commit
b833f36c75
@ -1739,7 +1739,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter">
|
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter,groq">
|
||||||
<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,14 @@ async function registerFunctionTools(type, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkFunctionToolCalls(data) {
|
async function checkFunctionToolCalls(data) {
|
||||||
if ([chat_completion_sources.OPENAI, chat_completion_sources.CUSTOM, chat_completion_sources.MISTRALAI, chat_completion_sources.OPENROUTER].includes(oai_settings.chat_completion_source)) {
|
const oaiCompat = [
|
||||||
|
chat_completion_sources.OPENAI,
|
||||||
|
chat_completion_sources.CUSTOM,
|
||||||
|
chat_completion_sources.MISTRALAI,
|
||||||
|
chat_completion_sources.OPENROUTER,
|
||||||
|
chat_completion_sources.GROQ,
|
||||||
|
];
|
||||||
|
if (oaiCompat.includes(oai_settings.chat_completion_source)) {
|
||||||
if (!Array.isArray(data?.choices)) {
|
if (!Array.isArray(data?.choices)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2045,6 +2052,7 @@ export function isFunctionCallingSupported() {
|
|||||||
chat_completion_sources.MISTRALAI,
|
chat_completion_sources.MISTRALAI,
|
||||||
chat_completion_sources.CLAUDE,
|
chat_completion_sources.CLAUDE,
|
||||||
chat_completion_sources.OPENROUTER,
|
chat_completion_sources.OPENROUTER,
|
||||||
|
chat_completion_sources.GROQ,
|
||||||
];
|
];
|
||||||
return supportedSources.includes(oai_settings.chat_completion_source);
|
return supportedSources.includes(oai_settings.chat_completion_source);
|
||||||
}
|
}
|
||||||
|
@ -915,6 +915,18 @@ router.post('/generate', jsonParser, function (request, response) {
|
|||||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.GROQ);
|
apiKey = readSecret(request.user.directories, SECRET_KEYS.GROQ);
|
||||||
headers = {};
|
headers = {};
|
||||||
bodyParams = {};
|
bodyParams = {};
|
||||||
|
|
||||||
|
// 'required' tool choice is not supported by Groq
|
||||||
|
if (request.body.tool_choice === 'required') {
|
||||||
|
if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
|
||||||
|
request.body.tool_choice = request.body.tools.length > 1
|
||||||
|
? 'auto' :
|
||||||
|
{ type: 'function', function: { name: request.body.tools[0]?.function?.name } };
|
||||||
|
|
||||||
|
} else {
|
||||||
|
request.body.tool_choice = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('This chat completion source is not supported yet.');
|
console.log('This chat completion source is not supported yet.');
|
||||||
return response.status(400).send({ error: true });
|
return response.status(400).send({ error: true });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user