Skip to content

Commit

Permalink
model selection is accurate now, and lots of files moved to be more a…
Browse files Browse the repository at this point in the history
…ccurate
  • Loading branch information
andrewpareles committed Dec 16, 2024
1 parent a42ff2d commit 8b25f80
Show file tree
Hide file tree
Showing 28 changed files with 462 additions and 438 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"jsdoc",
"header",
"local"
// "react" // Void
],
"rules": {
"constructor-super": "warn",
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/void/browser/void.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// llmMessage
import '../common/llmMessageService.js'

// voidConfig
import '../common/voidConfigService.js'
// voidSettings
import '../common/voidSettingsService.js'

// refreshModel
import '../common/refreshModelService.js'
Expand Down
10 changes: 5 additions & 5 deletions src/vs/platform/void/common/llmMessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { generateUuid } from '../../../base/common/uuid.js';
import { createDecorator } from '../../instantiation/common/instantiation.js';
import { Event } from '../../../base/common/event.js';
import { Disposable } from '../../../base/common/lifecycle.js';
import { IVoidConfigStateService } from './voidConfigService.js';
import { IVoidSettingsService } from './voidSettingsService.js';
// import { INotificationService } from '../../notification/common/notification.js';

// calls channel to implement features
Expand Down Expand Up @@ -42,7 +42,7 @@ export class LLMMessageService extends Disposable implements ILLMMessageService

constructor(
@IMainProcessService private readonly mainProcessService: IMainProcessService, // used as a renderer (only usable on client side)
@IVoidConfigStateService private readonly voidConfigStateService: IVoidConfigStateService,
@IVoidSettingsService private readonly voidSettingsService: IVoidSettingsService,
// @INotificationService private readonly notificationService: INotificationService,
) {
super()
Expand Down Expand Up @@ -79,7 +79,7 @@ export class LLMMessageService extends Disposable implements ILLMMessageService
const { featureName } = proxyParams

// end early if no provider
const modelSelection = this.voidConfigStateService.state.modelSelectionOfFeature[featureName]
const modelSelection = this.voidSettingsService.state.modelSelectionOfFeature[featureName]
if (modelSelection === null) {
onError({ message: 'Please add a Provider in Settings!', fullError: null })
return null
Expand All @@ -92,7 +92,7 @@ export class LLMMessageService extends Disposable implements ILLMMessageService
this.onFinalMessageHooks_llm[requestId_] = onFinalMessage
this.onErrorHooks_llm[requestId_] = onError

const { settingsOfProvider } = this.voidConfigStateService.state
const { settingsOfProvider } = this.voidSettingsService.state

// params will be stripped of all its functions over the IPC channel
this.channel.call('sendLLMMessage', {
Expand All @@ -116,7 +116,7 @@ export class LLMMessageService extends Disposable implements ILLMMessageService
ollamaList = (params: ServiceOllamaListParams) => {
const { onSuccess, onError, ...proxyParams } = params

const { settingsOfProvider } = this.voidConfigStateService.state
const { settingsOfProvider } = this.voidSettingsService.state

// add state for request id
const requestId_ = generateUuid();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/void/common/llmMessageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { IRange } from '../../../editor/common/core/range'
import { ProviderName, SettingsOfProvider } from './voidConfigTypes'
import { ProviderName, SettingsOfProvider } from './voidSettingsTypes.js'


export type OnText = (p: { newText: string, fullText: string }) => void
Expand Down
14 changes: 7 additions & 7 deletions src/vs/platform/void/common/refreshModelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { createDecorator } from '../../instantiation/common/instantiation.js';
import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
import { IVoidConfigStateService } from './voidConfigService.js';
import { IVoidSettingsService } from './voidSettingsService.js';
import { ILLMMessageService } from './llmMessageService.js';
import { Emitter, Event } from '../../../base/common/event.js';
import { Disposable } from '../../../base/common/lifecycle.js';
Expand Down Expand Up @@ -38,19 +38,19 @@ export class RefreshModelService extends Disposable implements IRefreshModelServ
readonly onDidChangeState: Event<void> = this._onDidChangeState.event; // this is primarily for use in react, so react can listen + update on state changes

constructor(
@IVoidConfigStateService private readonly voidConfigStateService: IVoidConfigStateService,
@IVoidSettingsService private readonly voidSettingsService: IVoidSettingsService,
@ILLMMessageService private readonly llmMessageService: ILLMMessageService,
) {
super()

// on mount, refresh ollama models
this.refreshOllamaModels()

// every time ollama.enabled changes, refresh ollama models
let relevantVals = () => [this.voidConfigStateService.state.settingsOfProvider.ollama.enabled, this.voidConfigStateService.state.settingsOfProvider.ollama.endpoint]
// every time ollama.enabled changes, refresh ollama models, like useEffect
let relevantVals = () => [this.voidSettingsService.state.settingsOfProvider.ollama.enabled, this.voidSettingsService.state.settingsOfProvider.ollama.endpoint]
let prevVals = relevantVals()
this._register(
this.voidConfigStateService.onDidChangeState(() => { // we might want to debounce this
this.voidSettingsService.onDidChangeState(() => { // we might want to debounce this
const newVals = relevantVals()
if (!eq(prevVals, newVals)) {
this.refreshOllamaModels()
Expand All @@ -75,7 +75,7 @@ export class RefreshModelService extends Disposable implements IRefreshModelServ
this._cancelTimeout()

// if ollama is disabled, obivously done
if (this.voidConfigStateService.state.settingsOfProvider.ollama.enabled !== 'true') {
if (this.voidSettingsService.state.settingsOfProvider.ollama.enabled !== 'true') {
this._setState('done')
return
}
Expand All @@ -85,7 +85,7 @@ export class RefreshModelService extends Disposable implements IRefreshModelServ

this.llmMessageService.ollamaList({
onSuccess: ({ models }) => {
this.voidConfigStateService.setSettingOfProvider('ollama', 'models', models.map(model => model.name))
this.voidSettingsService.setSettingOfProvider('ollama', 'models', models.map(model => model.name))
this._setState('done')
},
onError: ({ error }) => {
Expand Down
137 changes: 0 additions & 137 deletions src/vs/platform/void/common/voidConfigService.ts

This file was deleted.

Loading

0 comments on commit 8b25f80

Please sign in to comment.