mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-12-14 15:48:15 +00:00
feat(action-registry): use tool types, add tool methods
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
import { Tool, ToolCall } from '@/lib/models/types';
|
||||||
import {
|
import {
|
||||||
ActionConfig,
|
|
||||||
ActionOutput,
|
ActionOutput,
|
||||||
AdditionalConfig,
|
AdditionalConfig,
|
||||||
ClassifierOutput,
|
ClassifierOutput,
|
||||||
@@ -25,6 +25,18 @@ class ActionRegistry {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getAvailableActionTools(config: {
|
||||||
|
classification: ClassifierOutput;
|
||||||
|
}): Tool[] {
|
||||||
|
const availableActions = this.getAvailableActions(config);
|
||||||
|
|
||||||
|
return availableActions.map((action) => ({
|
||||||
|
name: action.name,
|
||||||
|
description: action.description,
|
||||||
|
schema: action.schema,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
static getAvailableActionsDescriptions(config: {
|
static getAvailableActionsDescriptions(config: {
|
||||||
classification: ClassifierOutput;
|
classification: ClassifierOutput;
|
||||||
}): string {
|
}): string {
|
||||||
@@ -50,7 +62,7 @@ class ActionRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async executeAll(
|
static async executeAll(
|
||||||
actions: ActionConfig[],
|
actions: ToolCall[],
|
||||||
additionalConfig: AdditionalConfig,
|
additionalConfig: AdditionalConfig,
|
||||||
): Promise<ActionOutput[]> {
|
): Promise<ActionOutput[]> {
|
||||||
const results: ActionOutput[] = [];
|
const results: ActionOutput[] = [];
|
||||||
@@ -58,8 +70,8 @@ class ActionRegistry {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
actions.map(async (actionConfig) => {
|
actions.map(async (actionConfig) => {
|
||||||
const output = await this.execute(
|
const output = await this.execute(
|
||||||
actionConfig.type,
|
actionConfig.name,
|
||||||
actionConfig.params,
|
actionConfig.arguments,
|
||||||
additionalConfig,
|
additionalConfig,
|
||||||
);
|
);
|
||||||
results.push(output);
|
results.push(output);
|
||||||
|
|||||||
Reference in New Issue
Block a user