mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-12-14 15:48:15 +00:00
feat(registry): update to send fileIds
This commit is contained in:
@@ -20,6 +20,7 @@ class ActionRegistry {
|
|||||||
|
|
||||||
static getAvailableActions(config: {
|
static getAvailableActions(config: {
|
||||||
classification: ClassifierOutput;
|
classification: ClassifierOutput;
|
||||||
|
fileIds: string[];
|
||||||
mode: SearchAgentConfig['mode'];
|
mode: SearchAgentConfig['mode'];
|
||||||
}): ResearchAction[] {
|
}): ResearchAction[] {
|
||||||
return Array.from(
|
return Array.from(
|
||||||
@@ -29,6 +30,7 @@ class ActionRegistry {
|
|||||||
|
|
||||||
static getAvailableActionTools(config: {
|
static getAvailableActionTools(config: {
|
||||||
classification: ClassifierOutput;
|
classification: ClassifierOutput;
|
||||||
|
fileIds: string[];
|
||||||
mode: SearchAgentConfig['mode'];
|
mode: SearchAgentConfig['mode'];
|
||||||
}): Tool[] {
|
}): Tool[] {
|
||||||
const availableActions = this.getAvailableActions(config);
|
const availableActions = this.getAvailableActions(config);
|
||||||
@@ -42,19 +44,26 @@ class ActionRegistry {
|
|||||||
|
|
||||||
static getAvailableActionsDescriptions(config: {
|
static getAvailableActionsDescriptions(config: {
|
||||||
classification: ClassifierOutput;
|
classification: ClassifierOutput;
|
||||||
|
fileIds: string[];
|
||||||
mode: SearchAgentConfig['mode'];
|
mode: SearchAgentConfig['mode'];
|
||||||
}): string {
|
}): string {
|
||||||
const availableActions = this.getAvailableActions(config);
|
const availableActions = this.getAvailableActions(config);
|
||||||
|
|
||||||
return availableActions
|
return availableActions
|
||||||
.map((action) => `<tool name="${action.name}">\n${action.getDescription({ mode: config.mode })}\n</tool>`)
|
.map(
|
||||||
|
(action) =>
|
||||||
|
`<tool name="${action.name}">\n${action.getDescription({ mode: config.mode })}\n</tool>`,
|
||||||
|
)
|
||||||
.join('\n\n');
|
.join('\n\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute(
|
static async execute(
|
||||||
name: string,
|
name: string,
|
||||||
params: any,
|
params: any,
|
||||||
additionalConfig: AdditionalConfig & { researchBlockId: string },
|
additionalConfig: AdditionalConfig & {
|
||||||
|
researchBlockId: string;
|
||||||
|
fileIds: string[];
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
const action = this.actions.get(name);
|
const action = this.actions.get(name);
|
||||||
|
|
||||||
@@ -67,7 +76,10 @@ class ActionRegistry {
|
|||||||
|
|
||||||
static async executeAll(
|
static async executeAll(
|
||||||
actions: ToolCall[],
|
actions: ToolCall[],
|
||||||
additionalConfig: AdditionalConfig & { researchBlockId: string },
|
additionalConfig: AdditionalConfig & {
|
||||||
|
researchBlockId: string;
|
||||||
|
fileIds: string[];
|
||||||
|
},
|
||||||
): Promise<ActionOutput[]> {
|
): Promise<ActionOutput[]> {
|
||||||
const results: ActionOutput[] = [];
|
const results: ActionOutput[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export type SearchSources = 'web' | 'discussions' | 'academic';
|
|||||||
|
|
||||||
export type SearchAgentConfig = {
|
export type SearchAgentConfig = {
|
||||||
sources: SearchSources[];
|
sources: SearchSources[];
|
||||||
|
fileIds: string[];
|
||||||
llm: BaseLLM<any>;
|
llm: BaseLLM<any>;
|
||||||
embedding: BaseEmbedding<any>;
|
embedding: BaseEmbedding<any>;
|
||||||
mode: 'speed' | 'balanced' | 'quality';
|
mode: 'speed' | 'balanced' | 'quality';
|
||||||
@@ -102,11 +103,16 @@ export interface ResearchAction<
|
|||||||
schema: z.ZodObject<any>;
|
schema: z.ZodObject<any>;
|
||||||
getToolDescription: (config: { mode: SearchAgentConfig['mode'] }) => string;
|
getToolDescription: (config: { mode: SearchAgentConfig['mode'] }) => string;
|
||||||
getDescription: (config: { mode: SearchAgentConfig['mode'] }) => string;
|
getDescription: (config: { mode: SearchAgentConfig['mode'] }) => string;
|
||||||
enabled: (config: { classification: ClassifierOutput, mode: SearchAgentConfig['mode'] }) => boolean;
|
enabled: (config: {
|
||||||
|
classification: ClassifierOutput;
|
||||||
|
fileIds: string[];
|
||||||
|
mode: SearchAgentConfig['mode'];
|
||||||
|
}) => boolean;
|
||||||
execute: (
|
execute: (
|
||||||
params: z.infer<TSchema>,
|
params: z.infer<TSchema>,
|
||||||
additionalConfig: AdditionalConfig & {
|
additionalConfig: AdditionalConfig & {
|
||||||
researchBlockId: string;
|
researchBlockId: string;
|
||||||
|
fileIds: string[];
|
||||||
},
|
},
|
||||||
) => Promise<ActionOutput>;
|
) => Promise<ActionOutput>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user