Compare commits

..

No commits in common. '79adc5fffbd07c900604a79fa3d4413f507e896b' and '0c1f85996ca206d3cb9ff7cba65fd1c7626eaae8' have entirely different histories.

@ -3,7 +3,7 @@ import { Agent } from "../types.js";
export const chefAgent: Agent = { export const chefAgent: Agent = {
id: "chef", id: "chef",
name: "Chef", name: "Chef",
modelName: "mistralai/mistral-nemo", modelName: "mistral/ministral-8b",
systemMessage: systemMessage:
"You are a master chef who is famous for his creative and original recipes, but also knows many standard, tried-and-true recipes.", "You are a master chef who is famous for his creative and original recipes, but also knows many standard, tried-and-true recipes.",
description: description:

@ -7,8 +7,7 @@ export const personalAssistantAgent: Agent = {
name: "Personal Assistant", name: "Personal Assistant",
// modelName: "qwen/qwen3-32b:free", // modelName: "qwen/qwen3-32b:free",
// modelName: "mistral/ministral-8b", // modelName: "mistral/ministral-8b",
// modelName: "google/gemini-2.5-flash-preview", modelName: "google/gemini-2.5-flash-preview",
modelName: "mistralai/mistral-nemo",
systemMessage: systemMessage:
singleSpace(`You are a personal assistant Agent who is helpful, friendly, and singleSpace(`You are a personal assistant Agent who is helpful, friendly, and
responsible. You are my liason to other Agents who have specialized responsible. You are my liason to other Agents who have specialized

@ -1,10 +1,4 @@
import { import { streamText } from "ai";
streamText,
generateText,
generateObject,
type Message,
jsonSchema,
} from "ai";
import { getAgentById, openrouter } from "./agentRegistry.js"; import { getAgentById, openrouter } from "./agentRegistry.js";
// Define the tools with explicit type // Define the tools with explicit type
@ -39,59 +33,26 @@ const tools: ToolFunctions = {
} }
try { try {
const conversation: { messages: Array<Omit<Message, "id">> } = { // Generate a response from the agent using the prompt
const result = streamText({
model: openrouter(agent.modelName),
messages: [ messages: [
{ role: "system", content: agent.systemMessage }, { role: "system", content: agent.systemMessage },
{ role: "user", content: prompt }, { role: "user", content: prompt },
], ],
}; tools: agent.tools,
let isConversationDone = false; });
while (!isConversationDone) {
// Generate a response from the agent using the prompt // Collect the response text
const result = await generateText({ let responseText = "";
model: openrouter(agent.modelName),
messages: conversation.messages, // The textStream is already an AsyncIterable, no need to call it as a function
tools: agent.tools, for await (const chunk of result.textStream) {
}); responseText += chunk;
conversation.messages.push({ role: "assistant", content: result.text });
const sentimentIsConversationDone = await generateObject<{
isConversationDone: boolean;
}>({
model: openrouter("mistralai/mistral-nemo"),
messages: [
{
role: "system",
content:
"You are a tool to determine whether a conversation is done or should continue with another reply.",
},
{
role: "user",
content: conversation.messages
.map((message) => `${message.role}: ${message.content}`)
.join("\n"),
},
],
schema: jsonSchema({
type: "object",
properties: {
isConversationDone: {
type: "boolean",
description:
"Whether the conversation is done or should continue and requires a reply.",
},
},
}),
});
isConversationDone =
sentimentIsConversationDone.object.isConversationDone;
} }
// const summaryText = await generateSummary(); // Return the agent's response
// // Return the agent's response return responseText;
// return summaryText;
return conversation.messages
.map((message) => `${message.role}: ${message.content}`)
.join("\n");
} catch (error: unknown) { } catch (error: unknown) {
const errorMessage = const errorMessage =
error instanceof Error ? error.message : "Unknown error"; error instanceof Error ? error.message : "Unknown error";

Loading…
Cancel
Save