mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-17 16:37:52 +00:00
update settings, add search files method
This commit is contained in:
parent
da488f1c39
commit
9488146162
@ -28,6 +28,7 @@ async function generatePrompt(
|
|||||||
cwd: string,
|
cwd: string,
|
||||||
supportsComputerUse: boolean,
|
supportsComputerUse: boolean,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
|
filesSearchMethod: string,
|
||||||
mcpHub?: McpHub,
|
mcpHub?: McpHub,
|
||||||
diffStrategy?: DiffStrategy,
|
diffStrategy?: DiffStrategy,
|
||||||
browserViewportSize?: string,
|
browserViewportSize?: string,
|
||||||
@ -43,8 +44,6 @@ async function generatePrompt(
|
|||||||
// throw new Error("Extension context is required for generating system prompt")
|
// throw new Error("Extension context is required for generating system prompt")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const searchTool = "semantic"
|
|
||||||
|
|
||||||
// If diff is disabled, don't pass the diffStrategy
|
// If diff is disabled, don't pass the diffStrategy
|
||||||
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
|
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
|
||||||
|
|
||||||
@ -66,7 +65,7 @@ ${getSharedToolUseSection()}
|
|||||||
${getToolDescriptionsForMode(
|
${getToolDescriptionsForMode(
|
||||||
mode,
|
mode,
|
||||||
cwd,
|
cwd,
|
||||||
searchTool,
|
filesSearchMethod,
|
||||||
supportsComputerUse,
|
supportsComputerUse,
|
||||||
effectiveDiffStrategy,
|
effectiveDiffStrategy,
|
||||||
browserViewportSize,
|
browserViewportSize,
|
||||||
@ -82,7 +81,7 @@ ${mcpServersSection}
|
|||||||
${getCapabilitiesSection(
|
${getCapabilitiesSection(
|
||||||
mode,
|
mode,
|
||||||
cwd,
|
cwd,
|
||||||
searchTool,
|
filesSearchMethod,
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${modesSection}
|
${modesSection}
|
||||||
@ -90,7 +89,7 @@ ${modesSection}
|
|||||||
${getRulesSection(
|
${getRulesSection(
|
||||||
mode,
|
mode,
|
||||||
cwd,
|
cwd,
|
||||||
searchTool,
|
filesSearchMethod,
|
||||||
supportsComputerUse,
|
supportsComputerUse,
|
||||||
effectiveDiffStrategy,
|
effectiveDiffStrategy,
|
||||||
experiments,
|
experiments,
|
||||||
@ -109,6 +108,7 @@ export const SYSTEM_PROMPT = async (
|
|||||||
cwd: string,
|
cwd: string,
|
||||||
supportsComputerUse: boolean,
|
supportsComputerUse: boolean,
|
||||||
mode: Mode = defaultModeSlug,
|
mode: Mode = defaultModeSlug,
|
||||||
|
filesSearchMethod: string = 'regex',
|
||||||
mcpHub?: McpHub,
|
mcpHub?: McpHub,
|
||||||
diffStrategy?: DiffStrategy,
|
diffStrategy?: DiffStrategy,
|
||||||
browserViewportSize?: string,
|
browserViewportSize?: string,
|
||||||
@ -158,6 +158,7 @@ export const SYSTEM_PROMPT = async (
|
|||||||
cwd,
|
cwd,
|
||||||
supportsComputerUse,
|
supportsComputerUse,
|
||||||
currentMode.slug,
|
currentMode.slug,
|
||||||
|
filesSearchMethod,
|
||||||
mcpHub,
|
mcpHub,
|
||||||
effectiveDiffStrategy,
|
effectiveDiffStrategy,
|
||||||
browserViewportSize,
|
browserViewportSize,
|
||||||
|
|||||||
@ -38,6 +38,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
|||||||
containerEl.empty()
|
containerEl.empty()
|
||||||
this.renderModelsSection(containerEl)
|
this.renderModelsSection(containerEl)
|
||||||
this.renderDeepResearchSection(containerEl)
|
this.renderDeepResearchSection(containerEl)
|
||||||
|
this.renderFilesSearchSection(containerEl)
|
||||||
this.renderRAGSection(containerEl)
|
this.renderRAGSection(containerEl)
|
||||||
this.renderAutoCompleteSection(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 {
|
renderModelsSection(containerEl: HTMLElement): void {
|
||||||
const modelsDiv = containerEl.createDiv("models-section");
|
const modelsDiv = containerEl.createDiv("models-section");
|
||||||
this.modelsContainer = modelsDiv;
|
this.modelsContainer = modelsDiv;
|
||||||
@ -73,7 +94,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
|||||||
.setName('Serper Api Key')
|
.setName('Serper Api Key')
|
||||||
.setDesc(createFragment(el => {
|
.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 ');
|
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',
|
href: 'https://serpapi.com/manage-api-key',
|
||||||
text: '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)')
|
.setName('Jina Api Key (Optional)')
|
||||||
.setDesc(createFragment(el => {
|
.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 ');
|
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',
|
href: 'https://jina.ai/api-key',
|
||||||
text: '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 {
|
private renderAutoCompleteContent(containerEl: HTMLElement): void {
|
||||||
const updateSettings = async (update: Partial<InfioSettings>) => {
|
const updateSettings = async (update: Partial<InfioSettings>) => {
|
||||||
await this.plugin.setSettings({
|
await this.plugin.setSettings({
|
||||||
...this.plugin.settings,
|
...this.plugin.settings,
|
||||||
...update
|
...update
|
||||||
});
|
});
|
||||||
|
|
||||||
// 只重新渲染 AutoComplete 部分
|
// 只重新渲染 AutoComplete 部分
|
||||||
if (this.autoCompleteContainer) {
|
if (this.autoCompleteContainer) {
|
||||||
this.autoCompleteContainer.empty();
|
this.autoCompleteContainer.empty();
|
||||||
this.renderAutoCompleteContent(this.autoCompleteContainer);
|
this.renderAutoCompleteContent(this.autoCompleteContainer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const errors = new Map();
|
const errors = new Map();
|
||||||
|
|||||||
@ -222,10 +222,13 @@ export const InfioSettingsSchema = z.object({
|
|||||||
// Mode
|
// Mode
|
||||||
mode: z.string().catch('ask'),
|
mode: z.string().catch('ask'),
|
||||||
|
|
||||||
// Web Search
|
// Deep Research
|
||||||
serperApiKey: z.string().catch(''),
|
serperApiKey: z.string().catch(''),
|
||||||
jinaApiKey: z.string().catch(''),
|
jinaApiKey: z.string().catch(''),
|
||||||
|
|
||||||
|
// Files Search
|
||||||
|
filesSearchMethod: z.enum(['regex', 'semantic', 'auto']).catch('auto'),
|
||||||
|
|
||||||
/// [compatible]
|
/// [compatible]
|
||||||
// activeModels [compatible]
|
// activeModels [compatible]
|
||||||
activeModels: z.array(
|
activeModels: z.array(
|
||||||
|
|||||||
@ -158,7 +158,15 @@ export class PromptGenerator {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
console.log('this.settings.mode', this.settings.mode)
|
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[] = [
|
const requestMessages: RequestMessage[] = [
|
||||||
systemMessage,
|
systemMessage,
|
||||||
@ -446,8 +454,8 @@ export class PromptGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getSystemMessageNew(mode: Mode): Promise<RequestMessage> {
|
private async getSystemMessageNew(mode: Mode, filesSearchMethod: string): Promise<RequestMessage> {
|
||||||
const systemPrompt = await SYSTEM_PROMPT(this.app.vault.getRoot().path, false, mode)
|
const systemPrompt = await SYSTEM_PROMPT(this.app.vault.getRoot().path, false, mode, filesSearchMethod)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
role: 'system',
|
role: 'system',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user