feat(registry): update to send fileIds

This commit is contained in:
ItzCrazyKns
2025-12-13 22:21:22 +05:30
parent 40b25a487b
commit 8d471ac40e
2 changed files with 22 additions and 4 deletions

View File

@@ -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[] = [];

View File

@@ -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>;
} }