feat(llm): redo chat storage, part 3

This commit is contained in:
perf3ct 2025-06-02 15:12:08 +00:00
parent f6af617f6b
commit dcab4caee3
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
3 changed files with 33 additions and 21 deletions

View File

@ -279,9 +279,19 @@ export class AIServiceManager implements IAIServiceManager {
// If a specific provider is requested and available, use it
if (options.model && options.model.includes(':')) {
const [providerName, modelName] = options.model.split(':');
// Check if this is a provider prefix (e.g., "ollama:qwen3:30b")
// vs a model name with version (e.g., "qwen3:30b")
const parts = options.model.split(':');
// Only treat as provider:model if the first part is a known provider
const knownProviders = ['openai', 'anthropic', 'ollama', 'local'];
const potentialProvider = parts[0];
if (knownProviders.includes(potentialProvider) && availableProviders.includes(potentialProvider as ServiceProviders)) {
// This is a provider:model format
const providerName = potentialProvider;
const modelName = parts.slice(1).join(':'); // Rejoin the rest as model name
if (availableProviders.includes(providerName as ServiceProviders)) {
try {
const modifiedOptions = { ...options, model: modelName };
log.info(`[AIServiceManager] Using provider ${providerName} from model prefix with modifiedOptions.stream: ${modifiedOptions.stream}`);
@ -291,6 +301,7 @@ export class AIServiceManager implements IAIServiceManager {
// If the specified provider fails, continue with the fallback providers
}
}
// If not a provider prefix, treat the entire string as a model name and continue with normal provider selection
}
// Try each provider in order until one succeeds

View File

@ -234,7 +234,8 @@ export class ModelSelectionStage extends BasePipelineStage<ModelSelectionInput,
// For backward compatibility, ensure model name is set without prefix
if (options.model && options.model.includes(':')) {
options.model = modelName || options.model.split(':')[1];
const parsed = this.parseModelIdentifier(options.model);
options.model = modelName || parsed.model;
}
log.info(`Set provider metadata: provider=${selectedProvider}, model=${modelName}`);