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
Name | Type | Description |
---|---|---|
task | string | The task for which an agent is needed. |
maxResult | number | Maximum number of agents to return (default 1). |
agents | array | List of agents to filter in vector database. |
agentLocation | AgentLocation | Location preference for agents (ALL, LOCAL_ONLY, REMOTE_ONLY). |
getFrom | FilterUsing | Filtering method (USE_AI, USE_VECTOR_DB, USE_BOTH). |
Returns:
Promise<any>
A promise that resolves with the agent details.Examples
// Example 1: Find a single agent for a task
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);