|
|
|
|
@ -27,17 +27,17 @@ export class ModelSelectionStage extends BasePipelineStage<ModelSelectionInput,
|
|
|
|
|
|
|
|
|
|
// Get default model based on provider precedence
|
|
|
|
|
let defaultModel = 'openai:gpt-3.5-turbo'; // Fallback default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Enable tools by default unless explicitly disabled
|
|
|
|
|
updatedOptions.enableTools = updatedOptions.enableTools !== false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add tools if not already provided
|
|
|
|
|
if (updatedOptions.enableTools && (!updatedOptions.tools || updatedOptions.tools.length === 0)) {
|
|
|
|
|
try {
|
|
|
|
|
// Import tool registry and fetch tool definitions
|
|
|
|
|
const toolRegistry = (await import('../../tools/tool_registry.js')).default;
|
|
|
|
|
const toolDefinitions = toolRegistry.getAllToolDefinitions();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (toolDefinitions.length > 0) {
|
|
|
|
|
updatedOptions.tools = toolDefinitions;
|
|
|
|
|
log.info(`Added ${toolDefinitions.length} tools to options`);
|
|
|
|
|
@ -47,7 +47,7 @@ export class ModelSelectionStage extends BasePipelineStage<ModelSelectionInput,
|
|
|
|
|
try {
|
|
|
|
|
const toolInitializer = await import('../../tools/tool_initializer.js');
|
|
|
|
|
await toolInitializer.default.initializeTools();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Try again after initialization
|
|
|
|
|
const reinitToolDefinitions = toolRegistry.getAllToolDefinitions();
|
|
|
|
|
updatedOptions.tools = reinitToolDefinitions;
|
|
|
|
|
@ -90,22 +90,11 @@ export class ModelSelectionStage extends BasePipelineStage<ModelSelectionInput,
|
|
|
|
|
const model = await options.getOption('ollamaDefaultModel');
|
|
|
|
|
if (model) {
|
|
|
|
|
defaultModel = `ollama:${model}`;
|
|
|
|
|
|
|
|
|
|
// Special configuration for Ollama
|
|
|
|
|
// Since Ollama models have different requirements for tool calling,
|
|
|
|
|
// configure based on the model being used
|
|
|
|
|
const modelLower = model.toLowerCase();
|
|
|
|
|
|
|
|
|
|
if (modelLower.includes('llama3') ||
|
|
|
|
|
modelLower.includes('mistral') ||
|
|
|
|
|
modelLower.includes('dolphin') ||
|
|
|
|
|
modelLower.includes('neural') ||
|
|
|
|
|
modelLower.includes('mist') ||
|
|
|
|
|
modelLower.includes('wizard')) {
|
|
|
|
|
// These models are known to support tool calling
|
|
|
|
|
log.info(`Using Ollama model ${model} with tool calling support`);
|
|
|
|
|
updatedOptions.enableTools = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enable tools for all Ollama models
|
|
|
|
|
// The Ollama API will handle models that don't support tool calling
|
|
|
|
|
log.info(`Using Ollama model ${model} with tool calling enabled`);
|
|
|
|
|
updatedOptions.enableTools = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|