mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-19 14:22:19 +01:00
fix ollam provider (#3858)
This commit is contained in:
committed by
GitHub
parent
08e2a3a331
commit
63de200f58
@@ -9,6 +9,7 @@ import { IFetcherService } from '../../../platform/networking/common/fetcherServ
|
||||
import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService';
|
||||
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
|
||||
import { byokKnownModelsToAPIInfo, resolveModelInfo } from '../common/byokProvider';
|
||||
import { OpenAIEndpoint } from '../node/openAIEndpoint';
|
||||
import { AbstractOpenAICompatibleLMProvider, LanguageModelChatConfiguration, OpenAICompatibleLanguageModelChatInformation } from './abstractLanguageModelChatProvider';
|
||||
import { IBYOKStorageService } from './byokStorageService';
|
||||
|
||||
@@ -125,6 +126,12 @@ export class OllamaLMProvider extends AbstractOpenAICompatibleLMProvider<OllamaC
|
||||
return configuration?.url ?? 'http://localhost:11434';
|
||||
}
|
||||
|
||||
protected override async createOpenAIEndPoint(model: OpenAICompatibleLanguageModelChatInformation<OllamaConfig>): Promise<OpenAIEndpoint> {
|
||||
const modelInfo = this.getModelInfo(model.id, model.url);
|
||||
const url = `${model.url}/v1/chat/completions`;
|
||||
return this._instantiationService.createInstance(OpenAIEndpoint, modelInfo, model.configuration?.apiKey ?? '', url);
|
||||
}
|
||||
|
||||
private async _getOllamaModelInfo(ollamaBaseUrl: string, modelId: string): Promise<IChatModelInformation> {
|
||||
const modelInfo = await this._fetchOllamaModelInformation(ollamaBaseUrl, modelId);
|
||||
const contextWindow = modelInfo?.model_info?.[`${modelInfo.model_info['general.architecture']}.context_length`] ?? 32768;
|
||||
|
||||
Reference in New Issue
Block a user