use web worker to run pglite

This commit is contained in:
duanfuxiang
2025-03-19 21:01:32 +08:00
parent 76288377c3
commit 679d7142eb
25 changed files with 985 additions and 461 deletions

View File

@@ -29,6 +29,7 @@ export type ParsedMsgBlock =
} | {
type: 'attempt_completion'
result: string
finish: boolean
} | {
type: 'search_and_replace'
path: string
@@ -44,7 +45,8 @@ export type ParsedMsgBlock =
finish: boolean
} | {
type: 'ask_followup_question'
question: string
question: string,
finish: boolean
} | {
type: 'list_files'
path: string
@@ -402,6 +404,7 @@ export function parseMsgBlocks(
parsedResult.push({
type: 'attempt_completion',
result,
finish: node.sourceCodeLocation.endTag !== undefined
})
lastEndOffset = endOffset
} else if (node.nodeName === 'ask_followup_question') {
@@ -425,6 +428,7 @@ export function parseMsgBlocks(
parsedResult.push({
type: 'ask_followup_question',
question,
finish: node.sourceCodeLocation.endTag !== undefined
})
lastEndOffset = endOffset
} else if (node.nodeName === 'switch_mode') {

View File

@@ -372,7 +372,7 @@ export class PromptGenerator {
? await getFileOrFolderContent(currentFile.file, this.app.vault)
: undefined
const currentFileContentPrompt = isNewChat && currentFileContent
const currentFileContentPrompt = isNewChat && currentFileContent && this.settings.mode !== 'research'
? `<current_file_content path="${currentFile.file.path}">\n${currentFileContent}\n</current_file_content>`
: undefined

View File

@@ -20,8 +20,6 @@ export async function webSearch(query: string, serperApiKey: string): Promise<st
return new Promise((resolve, reject) => {
const url = `${SERPER_BASE_URL}?q=${encodeURIComponent(query)}&engine=google&api_key=${serperApiKey}&num=20`;
console.log(url)
https.get(url, (res: any) => {
let data = '';
@@ -31,7 +29,6 @@ export async function webSearch(query: string, serperApiKey: string): Promise<st
res.on('end', () => {
try {
console.log(data)
let parsedData: SearchResponse;
try {
parsedData = JSON.parse(data);
@@ -90,8 +87,6 @@ export async function fetchUrlsContent(urls: string[], apiKey: string): Promise<
}
});
console.log('fetchUrlsContent', results);
Promise.all(results).then((texts) => {
resolve(texts.join('\n\n'));
}).catch((error) => {
@@ -123,8 +118,6 @@ function fetchJina(url: string, apiKey: string): Promise<string> {
});
res.on('end', () => {
console.log(data);
try {
// check if there is an error response
const response = JSON.parse(data);