mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-16 08:21:55 +00:00
update settings
This commit is contained in:
parent
e3f54d4c26
commit
03c467753a
@ -5,6 +5,7 @@ import {
|
||||
MAX_DELAY, MAX_MAX_CHAR_LIMIT,
|
||||
MIN_DELAY,
|
||||
MIN_MAX_CHAR_LIMIT,
|
||||
MIN_MAX_TOKENS,
|
||||
azureOAIApiSettingsSchema,
|
||||
fewShotExampleSchema,
|
||||
modelOptionsSchema,
|
||||
@ -151,7 +152,7 @@ export const DEFAULT_SETTINGS = {
|
||||
top_p: 0.1,
|
||||
frequency_penalty: 0.25,
|
||||
presence_penalty: 0,
|
||||
max_tokens: 800,
|
||||
max_tokens: MIN_MAX_TOKENS,
|
||||
},
|
||||
// Prompt settings
|
||||
systemMessage: `Your job is to predict the most logical text that should be written at the location of the <mask/>.
|
||||
|
||||
@ -454,4 +454,82 @@ describe('settings migration', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('should migrate max_tokens from old value to new minimum', () => {
|
||||
// Test case: user has old max_tokens value (800) that needs to be migrated
|
||||
const settingsWithOldMaxTokens = {
|
||||
version: 0.4,
|
||||
modelOptions: {
|
||||
temperature: 1,
|
||||
top_p: 0.1,
|
||||
frequency_penalty: 0.25,
|
||||
presence_penalty: 0,
|
||||
max_tokens: 800, // Old value that's below new minimum
|
||||
},
|
||||
// Include other required fields for valid settings
|
||||
autocompleteEnabled: true,
|
||||
advancedMode: false,
|
||||
apiProvider: 'openai',
|
||||
triggers: DEFAULT_SETTINGS.triggers,
|
||||
delay: 500,
|
||||
systemMessage: DEFAULT_SETTINGS.systemMessage,
|
||||
fewShotExamples: DEFAULT_SETTINGS.fewShotExamples,
|
||||
userMessageTemplate: '{{prefix}}<mask/>{{suffix}}',
|
||||
chainOfThoughRemovalRegex: '(.|\\n)*ANSWER:',
|
||||
dontIncludeDataviews: true,
|
||||
maxPrefixCharLimit: 4000,
|
||||
maxSuffixCharLimit: 4000,
|
||||
removeDuplicateMathBlockIndicator: true,
|
||||
removeDuplicateCodeBlockIndicator: true,
|
||||
ignoredFilePatterns: '**/secret/**\n',
|
||||
ignoredTags: '',
|
||||
cacheSuggestions: true,
|
||||
debugMode: false,
|
||||
}
|
||||
|
||||
const result = parseInfioSettings(settingsWithOldMaxTokens)
|
||||
|
||||
// Should successfully parse and migrate max_tokens to 4096
|
||||
expect(result.modelOptions.max_tokens).toBe(4096)
|
||||
expect(result.version).toBe(0.5)
|
||||
})
|
||||
|
||||
it('should not change max_tokens if it is already above minimum', () => {
|
||||
// Test case: user has max_tokens already above minimum
|
||||
const settingsWithValidMaxTokens = {
|
||||
version: 0.4,
|
||||
modelOptions: {
|
||||
temperature: 1,
|
||||
top_p: 0.1,
|
||||
frequency_penalty: 0.25,
|
||||
presence_penalty: 0,
|
||||
max_tokens: 6000, // Already above minimum
|
||||
},
|
||||
// Include other required fields for valid settings
|
||||
autocompleteEnabled: true,
|
||||
advancedMode: false,
|
||||
apiProvider: 'openai',
|
||||
triggers: DEFAULT_SETTINGS.triggers,
|
||||
delay: 500,
|
||||
systemMessage: DEFAULT_SETTINGS.systemMessage,
|
||||
fewShotExamples: DEFAULT_SETTINGS.fewShotExamples,
|
||||
userMessageTemplate: '{{prefix}}<mask/>{{suffix}}',
|
||||
chainOfThoughRemovalRegex: '(.|\\n)*ANSWER:',
|
||||
dontIncludeDataviews: true,
|
||||
maxPrefixCharLimit: 4000,
|
||||
maxSuffixCharLimit: 4000,
|
||||
removeDuplicateMathBlockIndicator: true,
|
||||
removeDuplicateCodeBlockIndicator: true,
|
||||
ignoredFilePatterns: '**/secret/**\n',
|
||||
ignoredTags: '',
|
||||
cacheSuggestions: true,
|
||||
debugMode: false,
|
||||
}
|
||||
|
||||
const result = parseInfioSettings(settingsWithValidMaxTokens)
|
||||
|
||||
// Should keep the existing max_tokens value since it's already valid
|
||||
expect(result.modelOptions.max_tokens).toBe(6000)
|
||||
expect(result.version).toBe(0.5)
|
||||
})
|
||||
})
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
MAX_MAX_CHAR_LIMIT,
|
||||
MIN_DELAY,
|
||||
MIN_MAX_CHAR_LIMIT,
|
||||
MIN_MAX_TOKENS,
|
||||
fewShotExampleSchema,
|
||||
modelOptionsSchema
|
||||
} from '../settings/versions/shared';
|
||||
@ -13,7 +14,7 @@ import { DEFAULT_SETTINGS } from "../settings/versions/v1/v1";
|
||||
import { ApiProvider } from '../types/llm/model';
|
||||
import { isRegexValid, isValidIgnorePattern } from '../utils/auto-complete';
|
||||
|
||||
export const SETTINGS_SCHEMA_VERSION = 0.4
|
||||
export const SETTINGS_SCHEMA_VERSION = 0.5
|
||||
|
||||
const InfioProviderSchema = z.object({
|
||||
name: z.literal('Infio'),
|
||||
@ -432,9 +433,28 @@ const MIGRATIONS: Migration[] = [
|
||||
{
|
||||
fromVersion: 0.1,
|
||||
toVersion: 0.4,
|
||||
migrate: (data) => {
|
||||
const newData = { ...data }
|
||||
newData.version = 0.4
|
||||
return newData
|
||||
},
|
||||
},
|
||||
{
|
||||
fromVersion: 0.4,
|
||||
toVersion: 0.5,
|
||||
migrate: (data) => {
|
||||
const newData = { ...data }
|
||||
newData.version = SETTINGS_SCHEMA_VERSION
|
||||
|
||||
// Handle max_tokens minimum value increase from 800 to 4096
|
||||
if (newData.modelOptions && typeof newData.modelOptions === 'object') {
|
||||
const modelOptions = newData.modelOptions as Record<string, any>
|
||||
if (typeof modelOptions.max_tokens === 'number' && modelOptions.max_tokens < MIN_MAX_TOKENS) {
|
||||
console.log(`Updating max_tokens from ${modelOptions.max_tokens} to ${MIN_MAX_TOKENS} due to minimum value change`)
|
||||
modelOptions.max_tokens = MIN_MAX_TOKENS
|
||||
}
|
||||
}
|
||||
|
||||
return newData
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user