You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ai-net/server/agents/personalAssistant.ts

133 lines
4.5 KiB
TypeScript

import { jsonSchema, tool } from "ai";
import { Agent } from "../types.js";
import { singleSpace } from "../util.js";
export const personalAssistantAgent: Agent = {
id: "personal-assistant",
name: "Personal Assistant",
// modelName: "qwen/qwen3-32b:free",
// modelName: "mistral/ministral-8b",
modelName: "google/gemini-2.5-flash-preview",
systemMessage:
singleSpace(`You are a personal assistant Agent who is helpful, friendly, and
responsible. You are my liason to other Agents who have specialized
abilities and skills. I will inform you of the existence of these Agents by
giving you each one's "Agent Card" in a structured format. You will delegate
tasks to the Agent(s) that you deem most suitable, based on their skills and abilities. You
will provide those Agents with the necessary information and context
to complete the task effectively and efficiently; you will not include
irrelevant details, and you will include relevant details and context.
You may delegate to multiple Agents if the task or request can be split
into subtasks each requiring distinct skills/abilities. If multiple Agents
are equally-qualified to handle the task, you will ask me which one to delegate
to, because you are responsible and do not want to choose anything but the most
relevant Agent for a given task. Similarly, if you think there is no
sufficiently-capable Agent to handle a given task, you will tell me so and exit
the conversation so I can go create one.`),
description:
"A personal assistant who is helpful, friendly, and knowledgeable.",
skills: [
{
id: "help",
name: "Help",
description: "Provides helpful information.",
tags: ["help", "information"],
examples: [
"What is the weather like today?",
"How do I cook a lasagna?",
"Can you tell me about the history of the United States?",
],
},
],
tools: {
delegate: tool({
description:
"Delegate the task to another Agent that you deem most suitable.",
parameters: jsonSchema<{ agentId: string; prompt: string }>({
type: "object",
properties: {
agentId: {
type: "string",
description: "The ID of the Agent to delegate the task to.",
},
prompt: {
type: "string",
description:
"The prompt to use for the delegated task which includes all necessary information and context for the Agent to be able to complete the task.",
},
},
}),
// execute: async ({
// agentId,
// prompt,
// }: {
// agentId: string;
// prompt: string;
// }) => {
// const agent = agents.find((agent) => agent.id === agentId);
// if (!agent) {
// throw new Error(`No such agent: ${agentId}`);
// }
// const response = conversation.send({
// role: "user",
// content: prompt,
// });
// await response.consumeStream();
// for (const message of (await response.response).messages) {
// conversation.messages.push(message);
// }
// },
}),
// say: tool({
// description: "Say something.",
// parameters: jsonSchema<{ message: string }>({
// type: "object",
// properties: {
// message: {
// type: "string",
// description: "The message to say.",
// },
// },
// }),
// execute: async ({ message }: { message: string }) => {
// return message;
// },
// }),
exit: tool({
description: "Exits the conversation.",
parameters: jsonSchema<{ exitCode: number }>({
type: "object",
properties: {
exitCode: {
type: "number",
description: "The exit code to use.",
default: 0,
},
},
}),
}),
get_random_number: tool({
description: "Get a random number between `min` and `max`.",
parameters: jsonSchema<{ min: number; max: number }>({
type: "object",
properties: {
min: {
type: "number",
description: "The minimum value.",
default: 0,
},
max: {
type: "number",
description: "The maximum value.",
default: 1,
},
},
}),
execute: async ({ min = 0, max = 1 }: { min?: number; max?: number }) => {
return Math.random() * (max - min) + min;
},
}),
},
};