mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 09:26:33 +01:00
Fix Claude function tools with prefills
This commit is contained in:
parent
2aeaf43c28
commit
24b6f99abf
@ -138,6 +138,10 @@ async function sendClaudeRequest(request, response) {
|
||||
requestBody.system = converted_prompt.systemPrompt;
|
||||
}
|
||||
if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
|
||||
// Claude doesn't do prefills on function calls, and doesn't allow empty messages
|
||||
if (converted_prompt.messages.length && converted_prompt.messages[converted_prompt.messages.length - 1].role === 'assistant') {
|
||||
converted_prompt.messages.push({ role: 'user', content: '.' });
|
||||
}
|
||||
additionalHeaders['anthropic-beta'] = 'tools-2024-05-16';
|
||||
requestBody.tool_choice = { type: request.body.tool_choice === 'required' ? 'any' : 'auto' };
|
||||
requestBody.tools = request.body.tools
|
||||
|
Loading…
Reference in New Issue
Block a user