mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
finish merge errors
This commit is contained in:
parent
d8b6b3c306
commit
0db0513752
6 changed files with 43 additions and 32 deletions
|
|
@ -209,13 +209,8 @@ export type ProviderName = keyof typeof voidProviderDefaults
|
|||
export const providerNames = Object.keys(voidProviderDefaults) as ProviderName[]
|
||||
|
||||
|
||||
export const featureNames = ['Ctrl+L', 'Ctrl+K', 'Autocomplete']
|
||||
export type FeatureName = typeof featureNames[number]
|
||||
|
||||
|
||||
|
||||
|
||||
export type VoidConfigState = {
|
||||
export type VoidProviderState = {
|
||||
[providerName in ProviderName]: (
|
||||
{
|
||||
[optionName in keyof typeof voidProviderDefaults[providerName]]: string
|
||||
|
|
@ -233,7 +228,7 @@ export type VoidConfigState = {
|
|||
|
||||
type UnionOfKeys<T> = T extends T ? keyof T : never;
|
||||
|
||||
type SettingName = UnionOfKeys<VoidConfigState[ProviderName]>
|
||||
type ProviderSettingName = UnionOfKeys<VoidProviderState[ProviderName]>
|
||||
|
||||
|
||||
|
||||
|
|
@ -243,7 +238,7 @@ type DisplayInfo = {
|
|||
placeholder: string,
|
||||
}
|
||||
|
||||
export const displayInfoOfSettingName = (providerName: ProviderName, settingName: SettingName): DisplayInfo => {
|
||||
export const displayInfoOfSettingName = (providerName: ProviderName, settingName: ProviderSettingName): DisplayInfo => {
|
||||
if (settingName === 'apiKey') {
|
||||
return {
|
||||
title: 'API Key',
|
||||
|
|
@ -302,10 +297,7 @@ export const displayInfoOfSettingName = (providerName: ProviderName, settingName
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const defaultVoidConfigState: VoidConfigState = {
|
||||
export const defaultVoidProviderState: VoidProviderState = {
|
||||
anthropic: {
|
||||
...voidProviderDefaults.anthropic,
|
||||
...voidInitModelOptions.anthropic(),
|
||||
|
|
@ -352,3 +344,22 @@ export const defaultVoidConfigState: VoidConfigState = {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
type VoidFeatureState = {
|
||||
'Ctrl+L': {
|
||||
provider: ProviderName,
|
||||
model: string,
|
||||
} | null,
|
||||
'Ctrl+K': {
|
||||
provider: ProviderName,
|
||||
model: string,
|
||||
} | null,
|
||||
'Autocomplete': {
|
||||
provider: ProviderName,
|
||||
model: string,
|
||||
} | null,
|
||||
}
|
||||
export type FeatureName = keyof VoidFeatureState
|
||||
export const featureNames = ['Ctrl+L', 'Ctrl+K', 'Autocomplete']
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Void Editor additions licensed under the AGPLv3 License.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ProviderName, VoidConfigState } from './configTypes'
|
||||
import { ProviderName, VoidProviderState } from './configTypes'
|
||||
|
||||
|
||||
// ---------- type definitions ----------
|
||||
|
|
@ -27,7 +27,7 @@ export type LLMMessageServiceParams = {
|
|||
onError: OnError;
|
||||
|
||||
messages: LLMMessage[];
|
||||
voidConfig: VoidConfigState | null;
|
||||
voidConfig: VoidProviderState | null;
|
||||
|
||||
logging: {
|
||||
loggingName: string,
|
||||
|
|
@ -42,7 +42,7 @@ export type SendLLMMMessageParams = {
|
|||
onError: OnError;
|
||||
|
||||
messages: LLMMessage[];
|
||||
voidConfig: VoidConfigState | null;
|
||||
voidConfig: VoidProviderState | null;
|
||||
|
||||
logging: {
|
||||
loggingName: string,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ProviderName, VoidConfigState } from '../../common/configTypes'
|
||||
import { ProviderName, VoidProviderState } from '../../common/configTypes'
|
||||
import { LLMMessage, OnText, OnFinalMessage, OnError } from '../../common/llmMessageTypes'
|
||||
|
||||
export const parseMaxTokensStr = (maxTokensStr: string) => {
|
||||
|
|
@ -15,7 +15,7 @@ export type SendLLMMessageFnTypeInternal = (params: {
|
|||
onText: OnText;
|
||||
onFinalMessage: OnFinalMessage;
|
||||
onError: OnError;
|
||||
voidConfig: VoidConfigState;
|
||||
voidConfig: VoidProviderState;
|
||||
providerName: ProviderName;
|
||||
|
||||
_setAborter: (aborter: () => void) => void;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useState, useEffect } from 'react'
|
||||
import { VoidSidebarState, ReactServicesType } from '../../../registerSidebar.js'
|
||||
import { ThreadsState } from '../../../registerThreads.js'
|
||||
import { VoidConfigState } from '../../../../../../../platform/void/common/configTypes.js'
|
||||
import { VoidProviderState } from '../../../../../../../platform/void/common/configTypes.js'
|
||||
|
||||
|
||||
// normally to do this you'd use a useEffect that calls .onDidChangeState(), but useEffect mounts too late and misses initial state changes
|
||||
|
|
@ -10,12 +10,12 @@ let services: ReactServicesType
|
|||
|
||||
// even if React hasn't mounted yet, these variables are always updated to the latest state:
|
||||
let sidebarState: VoidSidebarState
|
||||
let configState: VoidConfigState
|
||||
let configState: VoidProviderState
|
||||
let threadsState: ThreadsState
|
||||
|
||||
// React listens by adding a setState function to these:
|
||||
const sidebarStateListeners: Set<(s: VoidSidebarState) => void> = new Set()
|
||||
const configStateListeners: Set<(s: VoidConfigState) => void> = new Set()
|
||||
const configStateListeners: Set<(s: VoidProviderState) => void> = new Set()
|
||||
const threadsStateListeners: Set<(s: ThreadsState) => void> = new Set()
|
||||
|
||||
// must call this before you can use any of the hooks below
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ export class AutocompleteService extends Disposable implements IAutocompleteServ
|
|||
}
|
||||
}
|
||||
|
||||
const { shouldGenerate, stopTokens } = getCompletionOptions({ prefix, suffix })
|
||||
const { shouldGenerate, stopTokens: _ } = getCompletionOptions({ prefix, suffix }) // TODO mat
|
||||
|
||||
if (!shouldGenerate) return []
|
||||
|
||||
|
|
@ -648,7 +648,6 @@ export class AutocompleteService extends Disposable implements IAutocompleteServ
|
|||
const requestId = this._sendLLMMessageService.sendLLMMessage({
|
||||
logging: { loggingName: 'Autocomplete' },
|
||||
messages: [],
|
||||
options: { prefix, suffix, stopTokens, },
|
||||
onText: async ({ newText, fullText }) => {
|
||||
|
||||
newAutocompletion.insertText = fullText
|
||||
|
|
@ -677,7 +676,8 @@ export class AutocompleteService extends Disposable implements IAutocompleteServ
|
|||
newAutocompletion.status = 'error'
|
||||
reject(error)
|
||||
},
|
||||
voidConfig: this._voidConfigStateService.state.voidConfig,
|
||||
providerName: 'anthropic',
|
||||
voidConfig: this._voidConfigStateService.state,
|
||||
})
|
||||
newAutocompletion.requestId = requestId
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { IEncryptionService } from '../../../../platform/encryption/common/encry
|
|||
import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js';
|
||||
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
|
||||
import { defaultVoidConfigState, ProviderName, VoidConfigState } from '../../../../platform/void/common/configTypes.js';
|
||||
import { defaultVoidProviderState, ProviderName, VoidProviderState } from '../../../../platform/void/common/configTypes.js';
|
||||
|
||||
|
||||
|
||||
|
|
@ -18,14 +18,14 @@ const VOID_CONFIG_KEY = 'void.partialVoidConfig'
|
|||
|
||||
type SetStateFn = <K extends ProviderName>(
|
||||
providerName: K,
|
||||
option: keyof VoidConfigState[K],
|
||||
option: keyof VoidProviderState[K],
|
||||
newVal: string
|
||||
) => Promise<void>;
|
||||
|
||||
|
||||
export interface IVoidConfigStateService {
|
||||
readonly _serviceBrand: undefined;
|
||||
readonly state: VoidConfigState;
|
||||
readonly state: VoidProviderState;
|
||||
onDidChangeState: Event<void>;
|
||||
setState: SetStateFn;
|
||||
}
|
||||
|
|
@ -37,11 +37,11 @@ class VoidConfigStateService extends Disposable implements IVoidConfigStateServi
|
|||
private readonly _onDidChangeState = new Emitter<void>();
|
||||
readonly onDidChangeState: Event<void> = this._onDidChangeState.event; // this is primarily for use in react, so react can listen + update on state changes
|
||||
|
||||
state: VoidConfigState;
|
||||
state: VoidProviderState;
|
||||
|
||||
// readonly voidConfigInfo: VoidConfigInfo = voidConfigInfo; // just putting this here for simplicity, it's static though
|
||||
get _defaultState() {
|
||||
return deepClone(defaultVoidConfigState)
|
||||
return deepClone(defaultVoidProviderState)
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class VoidConfigStateService extends Disposable implements IVoidConfigStateServi
|
|||
|
||||
|
||||
|
||||
private async _readVoidConfigState(): Promise<VoidConfigState> {
|
||||
private async _readVoidConfigState(): Promise<VoidProviderState> {
|
||||
const encryptedPartialConfig = this._storageService.get(VOID_CONFIG_KEY, StorageScope.APPLICATION)
|
||||
|
||||
if (!encryptedPartialConfig)
|
||||
|
|
@ -76,7 +76,7 @@ class VoidConfigStateService extends Disposable implements IVoidConfigStateServi
|
|||
}
|
||||
|
||||
|
||||
private async _storeVoidConfigState(voidConfigState: VoidConfigState) {
|
||||
private async _storeVoidConfigState(voidConfigState: VoidProviderState) {
|
||||
const encryptedVoidConfigStr = await this._encryptionService.encrypt(JSON.stringify(voidConfigState))
|
||||
this._storageService.store(VOID_CONFIG_KEY, encryptedVoidConfigStr, StorageScope.APPLICATION, StorageTarget.USER)
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ class VoidConfigStateService extends Disposable implements IVoidConfigStateServi
|
|||
|
||||
// Set field on PartialVoidConfig
|
||||
setState: SetStateFn = async (providerName, option, newVal) => {
|
||||
const newState: VoidConfigState = {
|
||||
const newState: VoidProviderState = {
|
||||
...this.state,
|
||||
[providerName]: {
|
||||
...this.state[providerName],
|
||||
|
|
@ -96,7 +96,7 @@ class VoidConfigStateService extends Disposable implements IVoidConfigStateServi
|
|||
}
|
||||
|
||||
// internal function to update state, should be called every time state changes
|
||||
private async _setState(voidConfigState: VoidConfigState) {
|
||||
private async _setState(voidConfigState: VoidProviderState) {
|
||||
this.state = voidConfigState
|
||||
this._onDidChangeState.fire()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue