Processing
Agent can respond with multiple messages, each separated by newlines. This allows for a structured approach a more natural conversation flow.
Overview
For processing to be effective we need to combine the following skills:
- Parsing: Interpret user intent and translate it into a defined skill.
- Definition: Define skills, parameters and handlers.
Example
User request
I want to check if vitalik.eth is available
Parsing
The agent will parse the response into an array of skills and messages. This happens in the processMultilineResponse
function.
gpt.ts
["Let me check that domain for you", "/check vitalik.eth"];
Execution
The agent will execute each skill in the array.
index.ts
for (const message of messages) {
// Check if the message is a command (starts with "/")
if (message.startsWith("/")) {
// Execute the skill associated with the command
const response = await context.executeSkill(message);
if (response && typeof response.message === "string") {
// Parse the response message
let msg = parseMarkdown(response.message);
// Add the parsed message to chat memory as a system message
chatMemory.addEntry(memoryKey, {
role: "system",
content: msg,
});
// Send the response message
await context.send(response.message);
}
} else {
// If the message is not a command, send it as is
await context.send(message);
}
}