ai: separate model and tool selection

This commit is contained in:
end-4
2025-07-27 22:33:25 +07:00
parent d3392000af
commit 3ac44d211f
10 changed files with 192 additions and 232 deletions
@@ -9,13 +9,12 @@ ApiStrategy {
return result;
}
function buildRequestData(model: AiModel, messages, systemPrompt: string, temperature: real) {
const tools = model.tools ?? [];
function buildRequestData(model: AiModel, messages, systemPrompt: string, temperature: real, tools: list<var>) {
let baseData = {
"contents": messages.map(message => {
const geminiApiRoleName = (message.role === "assistant") ? "model" : message.role;
const usingSearch = tools[0].google_search != undefined
if (!usingSearch && message.functionCall != undefined && message.functionCall.length > 0) {
const usingSearch = tools[0]?.google_search !== undefined
if (!usingSearch && message.functionCall != undefined && message.functionName.length > 0) {
return {
"role": geminiApiRoleName,
"parts": [{
@@ -25,7 +24,7 @@ ApiStrategy {
}]
}
}
if (!usingSearch && message.functionResponse != undefined && message.functionResponse.length > 0) {
if (!usingSearch && message.functionResponse != undefined && message.functionName.length > 0) {
return {
"role": geminiApiRoleName,
"parts": [{