Skip to content

Commit

Permalink
Update prompt to handle edge cases, specify agent usage in routing ag…
Browse files Browse the repository at this point in the history
…ent prompt
  • Loading branch information
huangjeff5 committed Dec 12, 2024
1 parent 72f820c commit a1d7b57
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
7 changes: 5 additions & 2 deletions samples/js-schoolAgent/src/attendanceAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { ai } from './genkit.js';
import { reportAbsence, reportTardy } from './tools.js';
import { agentDescription, agentPrompt } from './util.js';
import { agentDescription } from './util.js';

const tools = [reportAbsence, reportTardy, 'routingAgent'];
const specialization = 'attendance';
Expand All @@ -36,7 +36,10 @@ export const attendanceAgent = ai.definePrompt(
tools,
},
` {{ role "system"}}
${agentPrompt(specialization)}
You are Bell, a helpful attendance assistance agent for Sparkyville High School.
A parent has been referred to you to handle a ${specialization}-related concern.
Use the tools available to you to assist the parent.
- Parents may only report absences for their own students.
- If you are unclear about any of the fields required to report an absence or tardy, request clarification before using the tool.
Expand Down
7 changes: 5 additions & 2 deletions samples/js-schoolAgent/src/gradesAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { ai } from './genkit.js';
import { getRecentGrades } from './tools.js';
import { agentDescription, agentPrompt } from './util.js';
import { agentDescription } from './util.js';

const tools = [getRecentGrades, 'routingAgent'];
const specialization = 'grades';
Expand All @@ -36,7 +36,10 @@ export const gradesAgent = ai.definePrompt(
tools,
},
` {{ role "system"}}
${agentPrompt(specialization)}
You are Bell, a helpful attendance assistance agent for Sparkyville High School.
A parent has been referred to you to handle a ${specialization}-related concern.
Use the tools available to you to assist the parent.
Guidelines:
- Parents may only view grades for their own students
Expand Down
22 changes: 17 additions & 5 deletions samples/js-schoolAgent/src/routingAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,26 @@ export const routingAgent = ai.definePrompt(
description: `This agent helps with answering inquiries and requests.`,
tools: [searchEvents, attendanceAgent, gradesAgent, upcomingHolidays],
},
`You are Bell, a helpful assistant that provides information to parents of Sparkyville High School students.
`You are Bell, the friendly AI office receptionist at Sparkyville High School.
Your job is to help answer inquiries from parents. Parents may ask you school-related questions, request grades or test scores,
or call in to let you know their child will be late or absent.
You have some specialized agents in different departments that you can transfer to.
1. Grades Agent - This agent can provide informtion about previous scores for assignments and tests.
2. Attendance Agent - This agent can help with attendance requests, such as marking a student as late/tardy or absent.
Use the information below and any tools made available to you to respond to the parent's requests.
=== Frequently Asked Questions
If the parent has an inquiry that you do not know the answer to, do NOT make the answer up. Simply let them know that you cannot help them,
and direct them to call the office directly where a human will be able to help them.
=== Frequently Asked Questions
- Classes begin at 8am, students are dismissed at 3:30pm
- Parking permits are issued on a first-come first-serve basis beginning Aug 1
- Classes begin at 8am, students are dismissed at 3:30pm
- Parking permits are issued on a first-come first-serve basis beginning Aug 1
{{userContext @state }}
{{userContext @state }}
`
);
3 changes: 2 additions & 1 deletion samples/js-schoolAgent/src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ async function handleChatResponse(
m.content
.filter((p) => !!p.toolRequest)
.map(
(p) => `${p.toolRequest.name}(${JSON.stringify(p.toolRequest.input)})`
(p) =>
`${p.toolRequest?.name}(${JSON.stringify(p.toolRequest?.input)})`
)
)
.flat()
Expand Down
5 changes: 0 additions & 5 deletions samples/js-schoolAgent/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@ export const agentDescription = (specialization: string, tools: string[]) => `
Transfer to this agent when the user asks about ${specialization}.
This agent can perform the following functions: ${tools.map((t) => t).join(', ')}.
Do not mention that you are transferring, just do it.`;

export const agentPrompt = (specialization: string) => `
You are Bell, a helpful attendance assistance agent for Sparkyville High School.
A parent has been referred to you to handle a ${specialization}-related concern.
Use the tools available to you to assist the parent.`;

0 comments on commit a1d7b57

Please sign in to comment.