mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
add ollama model fetcher, but proxy ignores its functions
This commit is contained in:
parent
abc7151cd6
commit
696abc39fd
10 changed files with 131 additions and 17 deletions
|
|
@ -6,7 +6,7 @@ The Void team put together this list of links to get up and running with VSCode'
|
||||||
|
|
||||||
- [How VSCode's sourcecode is organized](https://github.com/microsoft/vscode/wiki/Source-Code-Organization) - this explains where the entry point files are, what `browser/` and `common/` mean, etc. This is the most important read on this whole list! We recommend reading the whole thing.
|
- [How VSCode's sourcecode is organized](https://github.com/microsoft/vscode/wiki/Source-Code-Organization) - this explains where the entry point files are, what `browser/` and `common/` mean, etc. This is the most important read on this whole list! We recommend reading the whole thing.
|
||||||
|
|
||||||
- [Built-in VSCode Styles](https://code.visualstudio.com/api/references/theme-color) - CSS variables that are built into VSCode. Use `var(--vscode-{theme but replacing . with -})`. You can also see the [Webview Theming Guide](https://code.visualstudio.com/api/extension-guides/webview#theming-webview-content).
|
- [Built-in VSCode styles](https://code.visualstudio.com/api/references/theme-color) - CSS variables that are built into VSCode. Use `var(--vscode-{theme but replacing . with -})`. You can also see their [Webview theming guide](https://code.visualstudio.com/api/extension-guides/webview#theming-webview-content).
|
||||||
|
|
||||||
## Beginners / Getting started
|
## Beginners / Getting started
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,8 @@ import { ExtensionSignatureVerificationService, IExtensionSignatureVerificationS
|
||||||
import { LLMMessageChannel } from '../../platform/void/electron-main/llmMessageChannel.js';
|
import { LLMMessageChannel } from '../../platform/void/electron-main/llmMessageChannel.js';
|
||||||
import { IMetricsService } from '../../platform/void/common/metricsService.js';
|
import { IMetricsService } from '../../platform/void/common/metricsService.js';
|
||||||
import { MetricsMainService } from '../../platform/void/electron-main/metricsMainService.js';
|
import { MetricsMainService } from '../../platform/void/electron-main/metricsMainService.js';
|
||||||
|
import { OllamaListMainService } from '../../platform/void/electron-main/ollamaListMainService.js';
|
||||||
|
import { IOllamaListService } from '../../platform/void/common/ollamaListService.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main VS Code application. There will only ever be one instance,
|
* The main VS Code application. There will only ever be one instance,
|
||||||
|
|
@ -1107,6 +1109,7 @@ export class CodeApplication extends Disposable {
|
||||||
|
|
||||||
// Void main process services (required for services with a channel for comm between browser and electron-main (node))
|
// Void main process services (required for services with a channel for comm between browser and electron-main (node))
|
||||||
services.set(IMetricsService, new SyncDescriptor(MetricsMainService, undefined, false));
|
services.set(IMetricsService, new SyncDescriptor(MetricsMainService, undefined, false));
|
||||||
|
services.set(IOllamaListService, new SyncDescriptor(OllamaListMainService, undefined, false));
|
||||||
|
|
||||||
// Default Extensions Profile Init
|
// Default Extensions Profile Init
|
||||||
services.set(IExtensionsProfileScannerService, new SyncDescriptor(ExtensionsProfileScannerService, undefined, true));
|
services.set(IExtensionsProfileScannerService, new SyncDescriptor(ExtensionsProfileScannerService, undefined, true));
|
||||||
|
|
@ -1245,6 +1248,8 @@ export class CodeApplication extends Disposable {
|
||||||
// Void
|
// Void
|
||||||
const metricsChannel = ProxyChannel.fromService(accessor.get(IMetricsService), disposables);
|
const metricsChannel = ProxyChannel.fromService(accessor.get(IMetricsService), disposables);
|
||||||
mainProcessElectronServer.registerChannel('void-channel-metrics', metricsChannel);
|
mainProcessElectronServer.registerChannel('void-channel-metrics', metricsChannel);
|
||||||
|
const ollamaListChannel = ProxyChannel.fromService(accessor.get(IOllamaListService), disposables);
|
||||||
|
mainProcessElectronServer.registerChannel('void-channel-ollama-list', ollamaListChannel);
|
||||||
const sendLLMMessageChannel = new LLMMessageChannel(accessor.get(IMetricsService));
|
const sendLLMMessageChannel = new LLMMessageChannel(accessor.get(IMetricsService));
|
||||||
mainProcessElectronServer.registerChannel('void-channel-sendLLMMessage', sendLLMMessageChannel);
|
mainProcessElectronServer.registerChannel('void-channel-sendLLMMessage', sendLLMMessageChannel);
|
||||||
|
|
||||||
|
|
|
||||||
30
src/vs/platform/void/browser/ollamaListService.ts
Normal file
30
src/vs/platform/void/browser/ollamaListService.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Glass Devtools, Inc. All rights reserved.
|
||||||
|
* Void Editor additions licensed under the AGPL 3.0 License.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { ProxyChannel } from '../../../base/parts/ipc/common/ipc.js';
|
||||||
|
import { IMainProcessService } from '../../ipc/common/mainProcessService.js';
|
||||||
|
import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
|
||||||
|
import { IOllamaListService } from '../common/ollamaListService.js';
|
||||||
|
|
||||||
|
// BROWSER IMPLEMENTATION, calls channel
|
||||||
|
|
||||||
|
export class OllamaListService implements IOllamaListService {
|
||||||
|
|
||||||
|
readonly _serviceBrand: undefined;
|
||||||
|
private readonly ollamaListService: IOllamaListService;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@IMainProcessService mainProcessService: IMainProcessService // (only usable on client side)
|
||||||
|
) {
|
||||||
|
this.ollamaListService = ProxyChannel.toService<IOllamaListService>(mainProcessService.getChannel('void-channel-ollama-list'));
|
||||||
|
}
|
||||||
|
|
||||||
|
list: IOllamaListService['list'] = (...params) => {
|
||||||
|
this.ollamaListService.list(...params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
registerSingleton(IOllamaListService, OllamaListService, InstantiationType.Eager);
|
||||||
|
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
|
|
||||||
|
// --- browser ---
|
||||||
// metrics
|
// metrics
|
||||||
import '../browser/metricsService.js'
|
import '../browser/metricsService.js'
|
||||||
|
|
||||||
|
// ollamaList
|
||||||
|
import '../browser/ollamaListService.js'
|
||||||
|
|
||||||
|
// --- common ---
|
||||||
// llmMessage
|
// llmMessage
|
||||||
import '../browser/llmMessageService.js'
|
import '../browser/llmMessageService.js'
|
||||||
|
|
||||||
// voidConfig
|
// voidConfig
|
||||||
import '../common/voidConfigService.js'
|
import '../common/voidConfigService.js'
|
||||||
|
|
||||||
|
|
|
||||||
48
src/vs/platform/void/common/ollamaListService.ts
Normal file
48
src/vs/platform/void/common/ollamaListService.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Glass Devtools, Inc. All rights reserved.
|
||||||
|
* Void Editor additions licensed under the AGPL 3.0 License.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { createDecorator } from '../../instantiation/common/instantiation.js';
|
||||||
|
import { SettingsOfProvider } from './voidConfigTypes.js';
|
||||||
|
|
||||||
|
|
||||||
|
export type OllamaListFnParams = {
|
||||||
|
settingsOfProvider: SettingsOfProvider;
|
||||||
|
onSuccess: (param: { models: ModelResponse[] }) => void;
|
||||||
|
onError: (param: { error: any }) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface IOllamaListService {
|
||||||
|
readonly _serviceBrand: undefined;
|
||||||
|
list(params: OllamaListFnParams): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const IOllamaListService = createDecorator<IOllamaListService>('ollamaListService');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// These are from 'ollama' SDK
|
||||||
|
interface ModelDetails {
|
||||||
|
parent_model: string;
|
||||||
|
format: string;
|
||||||
|
family: string;
|
||||||
|
families: string[];
|
||||||
|
parameter_size: string;
|
||||||
|
quantization_level: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModelResponse = {
|
||||||
|
name: string;
|
||||||
|
modified_at: Date;
|
||||||
|
size: number;
|
||||||
|
digest: string;
|
||||||
|
details: ModelDetails;
|
||||||
|
expires_at: Date;
|
||||||
|
size_vram: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -28,8 +28,8 @@ type SetModelSelectionOfFeature = <K extends FeatureName>(
|
||||||
|
|
||||||
|
|
||||||
type VoidConfigState = {
|
type VoidConfigState = {
|
||||||
settingsOfProvider: SettingsOfProvider; // optionsOfProvider
|
readonly settingsOfProvider: SettingsOfProvider; // optionsOfProvider
|
||||||
modelSelectionOfFeature: ModelSelectionOfFeature; // stateOfFeature
|
readonly modelSelectionOfFeature: ModelSelectionOfFeature; // stateOfFeature
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IVoidConfigStateService {
|
export interface IVoidConfigStateService {
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,12 @@
|
||||||
* Void Editor additions licensed under the AGPL 3.0 License.
|
* Void Editor additions licensed under the AGPL 3.0 License.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { ModelResponse, Ollama } from 'ollama';
|
import { Ollama } from 'ollama';
|
||||||
import { SendLLMMessageFnTypeInternal } from '../../common/llmMessageTypes.js';
|
import { SendLLMMessageFnTypeInternal } from '../../common/llmMessageTypes.js';
|
||||||
import { parseMaxTokensStr } from './util.js';
|
import { parseMaxTokensStr } from './util.js';
|
||||||
import { SettingsOfProvider } from '../../common/voidConfigTypes.js';
|
import { OllamaListFnParams } from '../../common/ollamaListService.js';
|
||||||
|
|
||||||
|
export const getDefaultOllamaModels = async ({ onSuccess, onError, settingsOfProvider }: OllamaListFnParams) => {
|
||||||
type GetOllamaModelsFnType = (args: {
|
|
||||||
settingsOfProvider: SettingsOfProvider;
|
|
||||||
onSuccess: (param: { models: ModelResponse[] }) => void;
|
|
||||||
onError: (param: { error: any }) => void;
|
|
||||||
}) => void
|
|
||||||
|
|
||||||
export const getDefaultOllamaModels: GetOllamaModelsFnType = async ({ onSuccess, onError, settingsOfProvider }) => {
|
|
||||||
const thisConfig = settingsOfProvider.ollama
|
const thisConfig = settingsOfProvider.ollama
|
||||||
const ollama = new Ollama({ host: thisConfig.endpoint })
|
const ollama = new Ollama({ host: thisConfig.endpoint })
|
||||||
ollama.list()
|
ollama.list()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* Copyright (c) Glass Devtools, Inc. All rights reserved.
|
|
||||||
* Void Editor additions licensed under the AGPL 3.0 License.
|
|
||||||
*--------------------------------------------------------------------------------------------*/
|
|
||||||
24
src/vs/platform/void/electron-main/ollamaListMainService.ts
Normal file
24
src/vs/platform/void/electron-main/ollamaListMainService.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Glass Devtools, Inc. All rights reserved.
|
||||||
|
* Void Editor additions licensed under the AGPL 3.0 License.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { Disposable } from '../../../base/common/lifecycle.js';
|
||||||
|
|
||||||
|
import { IOllamaListService } from '../common/ollamaListService.js';
|
||||||
|
import { getDefaultOllamaModels } from './llmMessage/ollama.js';
|
||||||
|
|
||||||
|
|
||||||
|
export class OllamaListMainService extends Disposable implements IOllamaListService {
|
||||||
|
_serviceBrand: undefined;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
list: IOllamaListService['list'] = (...params) => {
|
||||||
|
return getDefaultOllamaModels(...params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,6 +46,7 @@ import { ISendLLMMessageService } from '../../../../platform/void/browser/llmMes
|
||||||
import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
|
import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
|
||||||
import { IViewsService } from '../../../services/views/common/viewsService.js';
|
import { IViewsService } from '../../../services/views/common/viewsService.js';
|
||||||
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
|
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
|
||||||
|
import { IOllamaListService } from '../../../../platform/void/common/ollamaListService.js';
|
||||||
|
|
||||||
|
|
||||||
// compare against search.contribution.ts and debug.contribution.ts, scm.contribution.ts (source control)
|
// compare against search.contribution.ts and debug.contribution.ts, scm.contribution.ts (source control)
|
||||||
|
|
@ -88,9 +89,20 @@ class VoidSidebarViewPane extends ViewPane {
|
||||||
@IOpenerService openerService: IOpenerService,
|
@IOpenerService openerService: IOpenerService,
|
||||||
@ITelemetryService telemetryService: ITelemetryService,
|
@ITelemetryService telemetryService: ITelemetryService,
|
||||||
@IHoverService hoverService: IHoverService,
|
@IHoverService hoverService: IHoverService,
|
||||||
|
@IVoidConfigStateService configStateService: IVoidConfigStateService,
|
||||||
|
@IOllamaListService ollamaListService: IOllamaListService,
|
||||||
) {
|
) {
|
||||||
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService)
|
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService)
|
||||||
|
|
||||||
|
console.log('calling Ollama list!!!')
|
||||||
|
ollamaListService.list({
|
||||||
|
onSuccess: ({ models }) => {
|
||||||
|
console.log('ollama models:', models)
|
||||||
|
}, onError: ({ error }) => {
|
||||||
|
console.error('ollama error:', error)
|
||||||
|
},
|
||||||
|
settingsOfProvider: configStateService.state.settingsOfProvider,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue