update settings, add search files method
This commit is contained in:
parent
da488f1c39
commit
9488146162
@ -28,6 +28,7 @@ async function generatePrompt(
|
||||
cwd: string,
|
||||
supportsComputerUse: boolean,
|
||||
mode: Mode,
|
||||
filesSearchMethod: string,
|
||||
mcpHub?: McpHub,
|
||||
diffStrategy?: DiffStrategy,
|
||||
browserViewportSize?: string,
|
||||
@ -43,8 +44,6 @@ async function generatePrompt(
|
||||
// throw new Error("Extension context is required for generating system prompt")
|
||||
// }
|
||||
|
||||
const searchTool = "semantic"
|
||||
|
||||
// If diff is disabled, don't pass the diffStrategy
|
||||
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
|
||||
|
||||
@ -66,7 +65,7 @@ ${getSharedToolUseSection()}
|
||||
${getToolDescriptionsForMode(
|
||||
mode,
|
||||
cwd,
|
||||
searchTool,
|
||||
filesSearchMethod,
|
||||
supportsComputerUse,
|
||||
effectiveDiffStrategy,
|
||||
browserViewportSize,
|
||||
@ -82,7 +81,7 @@ ${mcpServersSection}
|
||||
${getCapabilitiesSection(
|
||||
mode,
|
||||
cwd,
|
||||
searchTool,
|
||||
filesSearchMethod,
|
||||
)}
|
||||
|
||||
${modesSection}
|
||||
@ -90,7 +89,7 @@ ${modesSection}
|
||||
${getRulesSection(
|
||||
mode,
|
||||
cwd,
|
||||
searchTool,
|
||||
filesSearchMethod,
|
||||
supportsComputerUse,
|
||||
effectiveDiffStrategy,
|
||||
experiments,
|
||||
@ -109,6 +108,7 @@ export const SYSTEM_PROMPT = async (
|
||||
cwd: string,
|
||||
supportsComputerUse: boolean,
|
||||
mode: Mode = defaultModeSlug,
|
||||
filesSearchMethod: string = 'regex',
|
||||
mcpHub?: McpHub,
|
||||
diffStrategy?: DiffStrategy,
|
||||
browserViewportSize?: string,
|
||||
@ -158,6 +158,7 @@ export const SYSTEM_PROMPT = async (
|
||||
cwd,
|
||||
supportsComputerUse,
|
||||
currentMode.slug,
|
||||
filesSearchMethod,
|
||||
mcpHub,
|
||||
effectiveDiffStrategy,
|
||||
browserViewportSize,
|
||||
|
||||
@ -38,6 +38,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
containerEl.empty()
|
||||
this.renderModelsSection(containerEl)
|
||||
this.renderDeepResearchSection(containerEl)
|
||||
this.renderFilesSearchSection(containerEl)
|
||||
this.renderRAGSection(containerEl)
|
||||
this.renderAutoCompleteSection(containerEl)
|
||||
}
|
||||
@ -58,6 +59,26 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
);
|
||||
}
|
||||
|
||||
private renderFilesSearchSection(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl)
|
||||
.setHeading()
|
||||
.setName('Files Search Method')
|
||||
.setDesc('Choose the method to search for files.')
|
||||
.addDropdown((dropdown) =>
|
||||
dropdown
|
||||
.addOption('auto', 'Auto')
|
||||
.addOption('regex', 'Regex')
|
||||
.addOption('semantic', 'Semantic')
|
||||
.setValue(this.plugin.settings.filesSearchMethod)
|
||||
.onChange(async (value) => {
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
filesSearchMethod: value as 'regex' | 'semantic' | 'auto',
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
renderModelsSection(containerEl: HTMLElement): void {
|
||||
const modelsDiv = containerEl.createDiv("models-section");
|
||||
this.modelsContainer = modelsDiv;
|
||||
@ -73,7 +94,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
.setName('Serper Api Key')
|
||||
.setDesc(createFragment(el => {
|
||||
el.appendText('API key for web search functionality. Serper allows the plugin to search the internet for information, similar to a search engine. Get your key from ');
|
||||
const a = el.createEl('a', {
|
||||
const a = el.createEl('a', {
|
||||
href: 'https://serpapi.com/manage-api-key',
|
||||
text: 'https://serpapi.com/manage-api-key'
|
||||
});
|
||||
@ -96,7 +117,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
.setName('Jina Api Key (Optional)')
|
||||
.setDesc(createFragment(el => {
|
||||
el.appendText('API key for parsing web pages into markdown format. If not provided, local parsing will be used. Get your key from ');
|
||||
const a = el.createEl('a', {
|
||||
const a = el.createEl('a', {
|
||||
href: 'https://jina.ai/api-key',
|
||||
text: 'https://jina.ai/api-key'
|
||||
});
|
||||
@ -290,16 +311,16 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
|
||||
private renderAutoCompleteContent(containerEl: HTMLElement): void {
|
||||
const updateSettings = async (update: Partial<InfioSettings>) => {
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
...update
|
||||
});
|
||||
|
||||
// 只重新渲染 AutoComplete 部分
|
||||
if (this.autoCompleteContainer) {
|
||||
this.autoCompleteContainer.empty();
|
||||
this.renderAutoCompleteContent(this.autoCompleteContainer);
|
||||
}
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
...update
|
||||
});
|
||||
|
||||
// 只重新渲染 AutoComplete 部分
|
||||
if (this.autoCompleteContainer) {
|
||||
this.autoCompleteContainer.empty();
|
||||
this.renderAutoCompleteContent(this.autoCompleteContainer);
|
||||
}
|
||||
};
|
||||
|
||||
const errors = new Map();
|
||||
|
||||
@ -222,10 +222,13 @@ export const InfioSettingsSchema = z.object({
|
||||
// Mode
|
||||
mode: z.string().catch('ask'),
|
||||
|
||||
// Web Search
|
||||
// Deep Research
|
||||
serperApiKey: z.string().catch(''),
|
||||
jinaApiKey: z.string().catch(''),
|
||||
|
||||
// Files Search
|
||||
filesSearchMethod: z.enum(['regex', 'semantic', 'auto']).catch('auto'),
|
||||
|
||||
/// [compatible]
|
||||
// activeModels [compatible]
|
||||
activeModels: z.array(
|
||||
|
||||
@ -158,7 +158,15 @@ export class PromptGenerator {
|
||||
},
|
||||
]
|
||||
console.log('this.settings.mode', this.settings.mode)
|
||||
const systemMessage = await this.getSystemMessageNew(this.settings.mode)
|
||||
let filesSearchMethod = this.settings.filesSearchMethod
|
||||
if (filesSearchMethod === 'auto' && this.settings.embeddingModelId && this.settings.embeddingModelId !== '') {
|
||||
filesSearchMethod = 'semantic'
|
||||
} else {
|
||||
filesSearchMethod = 'regex'
|
||||
}
|
||||
|
||||
console.log('filesSearchMethod: ', filesSearchMethod)
|
||||
const systemMessage = await this.getSystemMessageNew(this.settings.mode, filesSearchMethod)
|
||||
|
||||
const requestMessages: RequestMessage[] = [
|
||||
systemMessage,
|
||||
@ -446,8 +454,8 @@ export class PromptGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private async getSystemMessageNew(mode: Mode): Promise<RequestMessage> {
|
||||
const systemPrompt = await SYSTEM_PROMPT(this.app.vault.getRoot().path, false, mode)
|
||||
private async getSystemMessageNew(mode: Mode, filesSearchMethod: string): Promise<RequestMessage> {
|
||||
const systemPrompt = await SYSTEM_PROMPT(this.app.vault.getRoot().path, false, mode, filesSearchMethod)
|
||||
|
||||
return {
|
||||
role: 'system',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user