mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-16 16:31:56 +00:00
344 lines
7.4 KiB
TypeScript
344 lines
7.4 KiB
TypeScript
import { DEFAULT_MODELS } from '../constants'
|
|
import { DEFAULT_SETTINGS } from '../settings/versions/v1/v1'
|
|
|
|
import { parseInfioSettings } from './settings'
|
|
|
|
describe('parseSmartCopilotSettings', () => {
|
|
it('should return default values for empty input', () => {
|
|
const result = parseInfioSettings({})
|
|
expect(result).toEqual({
|
|
version: 0.4,
|
|
activeModels: DEFAULT_MODELS,
|
|
infioApiKey: '',
|
|
openAIApiKey: '',
|
|
anthropicApiKey: '',
|
|
filesSearchMethod: 'auto',
|
|
fuzzyMatchThreshold: 0.85,
|
|
geminiApiKey: '',
|
|
groqApiKey: '',
|
|
deepseekApiKey: '',
|
|
chatModelId: '',
|
|
chatModelProvider: 'OpenRouter',
|
|
applyModelId: '',
|
|
applyModelProvider: 'OpenRouter',
|
|
embeddingModelId: '',
|
|
embeddingModelProvider: 'Google',
|
|
experimentalDiffStrategy: false,
|
|
defaultProvider: 'OpenRouter',
|
|
alibabaQwenProvider: {
|
|
name: 'AlibabaQwen',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
anthropicProvider: {
|
|
name: 'Anthropic',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
ollamaChatModel: {
|
|
baseUrl: '',
|
|
model: '',
|
|
},
|
|
openAICompatibleChatModel: {
|
|
baseUrl: '',
|
|
apiKey: '',
|
|
model: '',
|
|
},
|
|
ollamaApplyModel: {
|
|
baseUrl: '',
|
|
model: '',
|
|
},
|
|
openAICompatibleApplyModel: {
|
|
baseUrl: '',
|
|
apiKey: '',
|
|
model: '',
|
|
},
|
|
ollamaEmbeddingModel: {
|
|
baseUrl: '',
|
|
model: '',
|
|
},
|
|
systemPrompt: '',
|
|
ragOptions: {
|
|
chunkSize: 1000,
|
|
thresholdTokens: 8192,
|
|
minSimilarity: 0.0,
|
|
limit: 10,
|
|
excludePatterns: [],
|
|
includePatterns: [],
|
|
},
|
|
autocompleteEnabled: true,
|
|
advancedMode: false,
|
|
apiProvider: 'openai',
|
|
azureOAIApiSettings: '',
|
|
openAIApiSettings: '',
|
|
multiSearchReplaceDiffStrategy: true,
|
|
ollamaApiSettings: '',
|
|
triggers: DEFAULT_SETTINGS.triggers,
|
|
delay: 500,
|
|
modelOptions: {
|
|
temperature: 1,
|
|
top_p: 0.1,
|
|
frequency_penalty: 0.25,
|
|
presence_penalty: 0,
|
|
max_tokens: 800,
|
|
},
|
|
systemMessage: DEFAULT_SETTINGS.systemMessage,
|
|
fewShotExamples: DEFAULT_SETTINGS.fewShotExamples,
|
|
userMessageTemplate: '{{prefix}}<mask/>{{suffix}}',
|
|
chainOfThoughRemovalRegex: '(.|\\n)*ANSWER:',
|
|
dontIncludeDataviews: true,
|
|
jinaApiKey: '',
|
|
maxPrefixCharLimit: 4000,
|
|
maxSuffixCharLimit: 4000,
|
|
mode: 'ask',
|
|
defaultMention: 'none',
|
|
removeDuplicateMathBlockIndicator: true,
|
|
removeDuplicateCodeBlockIndicator: true,
|
|
ripgrepPath: '',
|
|
serperApiKey: '',
|
|
serperSearchEngine: 'google',
|
|
ignoredFilePatterns: '**/secret/**\n',
|
|
ignoredTags: '',
|
|
cacheSuggestions: true,
|
|
debugMode: false,
|
|
deepseekProvider: {
|
|
name: 'DeepSeek',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
googleProvider: {
|
|
name: 'Google',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
groqProvider: {
|
|
name: 'Groq',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
infioProvider: {
|
|
name: 'Infio',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
ollamaProvider: {
|
|
apiKey: 'ollama',
|
|
baseUrl: '',
|
|
name: 'Ollama',
|
|
useCustomUrl: true,
|
|
},
|
|
openaiProvider: {
|
|
name: 'OpenAI',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
openaicompatibleProvider: {
|
|
name: 'OpenAICompatible',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: true,
|
|
},
|
|
openrouterProvider: {
|
|
name: 'OpenRouter',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
siliconflowProvider: {
|
|
name: 'SiliconFlow',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('settings migration', () => {
|
|
it('should migrate from v0 to v1', () => {
|
|
const oldSettings = {
|
|
openAIApiKey: 'openai-api-key',
|
|
groqApiKey: 'groq-api-key',
|
|
anthropicApiKey: 'anthropic-api-key',
|
|
ollamaBaseUrl: 'http://localhost:11434',
|
|
chatModel: 'claude-3.5-sonnet-latest',
|
|
applyModel: 'gpt-4o-mini',
|
|
embeddingModel: 'text-embedding-3-small',
|
|
systemPrompt: 'system prompt',
|
|
ragOptions: {
|
|
chunkSize: 1000,
|
|
thresholdTokens: 8192,
|
|
minSimilarity: 0.0,
|
|
limit: 10,
|
|
},
|
|
}
|
|
|
|
const result = parseInfioSettings(oldSettings)
|
|
expect(result).toEqual({
|
|
version: 0.4,
|
|
activeModels: DEFAULT_MODELS,
|
|
infioApiKey: '',
|
|
openAIApiKey: '',
|
|
anthropicApiKey: '',
|
|
filesSearchMethod: 'auto',
|
|
fuzzyMatchThreshold: 0.85,
|
|
geminiApiKey: '',
|
|
groqApiKey: '',
|
|
deepseekApiKey: '',
|
|
chatModelId: '',
|
|
chatModelProvider: 'OpenRouter',
|
|
applyModelId: '',
|
|
applyModelProvider: 'OpenRouter',
|
|
embeddingModelId: '',
|
|
embeddingModelProvider: 'Google',
|
|
experimentalDiffStrategy: false,
|
|
defaultProvider: 'OpenRouter',
|
|
alibabaQwenProvider: {
|
|
name: 'AlibabaQwen',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
anthropicProvider: {
|
|
name: 'Anthropic',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
ollamaChatModel: {
|
|
baseUrl: '',
|
|
model: '',
|
|
},
|
|
openAICompatibleChatModel: {
|
|
baseUrl: '',
|
|
apiKey: '',
|
|
model: '',
|
|
},
|
|
ollamaApplyModel: {
|
|
baseUrl: '',
|
|
model: '',
|
|
},
|
|
openAICompatibleApplyModel: {
|
|
baseUrl: '',
|
|
apiKey: '',
|
|
model: '',
|
|
},
|
|
ollamaEmbeddingModel: {
|
|
baseUrl: '',
|
|
model: '',
|
|
},
|
|
systemPrompt: '',
|
|
ragOptions: {
|
|
chunkSize: 1000,
|
|
thresholdTokens: 8192,
|
|
minSimilarity: 0.0,
|
|
limit: 10,
|
|
excludePatterns: [],
|
|
includePatterns: [],
|
|
},
|
|
autocompleteEnabled: true,
|
|
advancedMode: false,
|
|
apiProvider: 'openai',
|
|
azureOAIApiSettings: '',
|
|
openAIApiSettings: '',
|
|
multiSearchReplaceDiffStrategy: true,
|
|
ollamaApiSettings: '',
|
|
triggers: DEFAULT_SETTINGS.triggers,
|
|
delay: 500,
|
|
modelOptions: {
|
|
temperature: 1,
|
|
top_p: 0.1,
|
|
frequency_penalty: 0.25,
|
|
presence_penalty: 0,
|
|
max_tokens: 800,
|
|
},
|
|
systemMessage: DEFAULT_SETTINGS.systemMessage,
|
|
fewShotExamples: DEFAULT_SETTINGS.fewShotExamples,
|
|
userMessageTemplate: '{{prefix}}<mask/>{{suffix}}',
|
|
chainOfThoughRemovalRegex: '(.|\\n)*ANSWER:',
|
|
dontIncludeDataviews: true,
|
|
jinaApiKey: '',
|
|
maxPrefixCharLimit: 4000,
|
|
maxSuffixCharLimit: 4000,
|
|
mode: 'ask',
|
|
defaultMention: 'none',
|
|
removeDuplicateMathBlockIndicator: true,
|
|
removeDuplicateCodeBlockIndicator: true,
|
|
ripgrepPath: '',
|
|
serperApiKey: '',
|
|
serperSearchEngine: 'google',
|
|
ignoredFilePatterns: '**/secret/**\n',
|
|
ignoredTags: '',
|
|
cacheSuggestions: true,
|
|
debugMode: false,
|
|
deepseekProvider: {
|
|
name: 'DeepSeek',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
googleProvider: {
|
|
name: 'Google',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
groqProvider: {
|
|
name: 'Groq',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
grokProvider: {
|
|
name: 'Grok',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
infioProvider: {
|
|
name: 'Infio',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
ollamaProvider: {
|
|
apiKey: 'ollama',
|
|
baseUrl: '',
|
|
name: 'Ollama',
|
|
useCustomUrl: true,
|
|
},
|
|
openaiProvider: {
|
|
name: 'OpenAI',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
openaicompatibleProvider: {
|
|
name: 'OpenAICompatible',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: true,
|
|
},
|
|
openrouterProvider: {
|
|
name: 'OpenRouter',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
siliconflowProvider: {
|
|
name: 'SiliconFlow',
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
useCustomUrl: false,
|
|
},
|
|
})
|
|
})
|
|
})
|