mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-31 20:22:27 +08:00
feat(llm): redo chat storage, part 3
This commit is contained in:
parent
f6af617f6b
commit
dcab4caee3
@ -279,9 +279,19 @@ export class AIServiceManager implements IAIServiceManager {
|
|||||||
|
|
||||||
// If a specific provider is requested and available, use it
|
// If a specific provider is requested and available, use it
|
||||||
if (options.model && options.model.includes(':')) {
|
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 {
|
try {
|
||||||
const modifiedOptions = { ...options, model: modelName };
|
const modifiedOptions = { ...options, model: modelName };
|
||||||
log.info(`[AIServiceManager] Using provider ${providerName} from model prefix with modifiedOptions.stream: ${modifiedOptions.stream}`);
|
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 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
|
// Try each provider in order until one succeeds
|
||||||
|
@ -234,7 +234,8 @@ export class ModelSelectionStage extends BasePipelineStage<ModelSelectionInput,
|
|||||||
|
|
||||||
// For backward compatibility, ensure model name is set without prefix
|
// For backward compatibility, ensure model name is set without prefix
|
||||||
if (options.model && options.model.includes(':')) {
|
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}`);
|
log.info(`Set provider metadata: provider=${selectedProvider}, model=${modelName}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user