mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-12-14 15:48:15 +00:00
feat(researcher): use reasoning
This commit is contained in:
@@ -5,7 +5,6 @@ import SessionManager from '@/lib/session';
|
|||||||
import { Message, ReasoningResearchBlock } from '@/lib/types';
|
import { Message, ReasoningResearchBlock } from '@/lib/types';
|
||||||
import formatChatHistoryAsString from '@/lib/utils/formatHistory';
|
import formatChatHistoryAsString from '@/lib/utils/formatHistory';
|
||||||
import { ToolCall } from '@/lib/models/types';
|
import { ToolCall } from '@/lib/models/types';
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
class Researcher {
|
class Researcher {
|
||||||
async research(
|
async research(
|
||||||
@@ -22,13 +21,15 @@ class Researcher {
|
|||||||
|
|
||||||
const availableTools = ActionRegistry.getAvailableActionTools({
|
const availableTools = ActionRegistry.getAvailableActionTools({
|
||||||
classification: input.classification,
|
classification: input.classification,
|
||||||
|
fileIds: input.config.fileIds,
|
||||||
mode: input.config.mode,
|
mode: input.config.mode,
|
||||||
});
|
});
|
||||||
|
|
||||||
const availableActionsDescription =
|
const availableActionsDescription =
|
||||||
ActionRegistry.getAvailableActionsDescriptions({
|
ActionRegistry.getAvailableActionsDescriptions({
|
||||||
classification: input.classification,
|
classification: input.classification,
|
||||||
mode: input.config.mode
|
fileIds: input.config.fileIds,
|
||||||
|
mode: input.config.mode,
|
||||||
});
|
});
|
||||||
|
|
||||||
const researchBlockId = crypto.randomUUID();
|
const researchBlockId = crypto.randomUUID();
|
||||||
@@ -59,6 +60,7 @@ class Researcher {
|
|||||||
input.config.mode,
|
input.config.mode,
|
||||||
i,
|
i,
|
||||||
maxIteration,
|
maxIteration,
|
||||||
|
input.config.fileIds,
|
||||||
);
|
);
|
||||||
|
|
||||||
const actionStream = input.config.llm.streamText({
|
const actionStream = input.config.llm.streamText({
|
||||||
@@ -83,7 +85,7 @@ class Researcher {
|
|||||||
if (partialRes.toolCallChunk.length > 0) {
|
if (partialRes.toolCallChunk.length > 0) {
|
||||||
partialRes.toolCallChunk.forEach((tc) => {
|
partialRes.toolCallChunk.forEach((tc) => {
|
||||||
if (
|
if (
|
||||||
tc.name === '___plan' &&
|
tc.name === '0_reasoning' &&
|
||||||
tc.arguments['plan'] &&
|
tc.arguments['plan'] &&
|
||||||
!reasoningEmitted &&
|
!reasoningEmitted &&
|
||||||
block &&
|
block &&
|
||||||
@@ -105,7 +107,7 @@ class Researcher {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
} else if (
|
} else if (
|
||||||
tc.name === '___plan' &&
|
tc.name === '0_reasoning' &&
|
||||||
tc.arguments['plan'] &&
|
tc.arguments['plan'] &&
|
||||||
reasoningEmitted &&
|
reasoningEmitted &&
|
||||||
block &&
|
block &&
|
||||||
@@ -162,6 +164,7 @@ class Researcher {
|
|||||||
embedding: input.config.embedding,
|
embedding: input.config.embedding,
|
||||||
session: session,
|
session: session,
|
||||||
researchBlockId: researchBlockId,
|
researchBlockId: researchBlockId,
|
||||||
|
fileIds: input.config.fileIds,
|
||||||
});
|
});
|
||||||
|
|
||||||
actionOutput.push(...actionResults);
|
actionOutput.push(...actionResults);
|
||||||
|
|||||||
Reference in New Issue
Block a user