Skip to main content

findAgent

codebolt.agent.findAgent(task: string, maxResult: number, agents: array, agentLocation: AgentLocation, getFrom: FilterUsing): Promise<any>
Finds an agent suitable for the specified task.

Parameters

NameTypeDescription
taskstringThe task for which an agent is needed.
maxResultnumberMaximum number of agents to return (default 1).
agentsarrayList of agents to filter in vector database (empty array for no filtering).
agentLocationAgentLocationLocation preference for agents (ALL, LOCAL_ONLY, REMOTE_ONLY). Default is ALL.
getFromFilterUsingFiltering method (USE_AI, USE_VECTOR_DB, USE_BOTH). Default is USE_VECTOR_DB.

Returns:

 Promise<any>
A promise that resolves with the agent details.

Examples

// Example 1: Find a single agent for a task using default parameters
const agent = await codebolt.agent.findAgent("dataProcessing");
console.log("Found Agent:", agent);

// Example 2: Find multiple agents with specific filters
const agents = await codebolt.agent.findAgent(
"imageProcessing",
3, // maxResult
[], // agents
codebolt.agent.AgentLocation.LOCAL_ONLY,
codebolt.agent.FilterUsing.USE_VECTOR_DB
);
console.log("Found Agents:", agents);

// Example 3: Find agents using AI filtering
const aiFilteredAgents = await codebolt.agent.findAgent(
"naturalLanguageProcessing",
2,
[],
codebolt.agent.AgentLocation.ALL,
codebolt.agent.FilterUsing.USE_AI
);
console.log("AI Filtered Agents:", aiFilteredAgents);