diff --git a/apps/rowboat/app/lib/copilot/copilot.ts b/apps/rowboat/app/lib/copilot/copilot.ts index 8d8e94fa..879da5f9 100644 --- a/apps/rowboat/app/lib/copilot/copilot.ts +++ b/apps/rowboat/app/lib/copilot/copilot.ts @@ -1,27 +1,22 @@ import z from "zod"; import { createOpenAI } from "@ai-sdk/openai"; import { generateObject, streamText } from "ai"; -import path from "path"; -import fs from "fs"; import { WithStringId } from "../types/types"; import { Workflow } from "../types/workflow_types"; import { CopilotChatContext, CopilotMessage } from "../types/copilot_types"; import { DataSource } from "../types/datasource_types"; import { PrefixLogger } from "../utils"; import zodToJsonSchema from "zod-to-json-schema"; +import { COPILOT_INSTRUCTIONS_EDIT_AGENT } from "./copilot_edit_agent"; +import { COPILOT_INSTRUCTIONS_MULTI_AGENT } from "./copilot_multi_agent"; +import { COPILOT_MULTI_AGENT_EXAMPLE_1 } from "./example_multi_agent_1"; +import { CURRENT_WORKFLOW_PROMPT } from "./current_workflow"; const PROVIDER_API_KEY = process.env.PROVIDER_API_KEY || process.env.OPENAI_API_KEY || ''; const PROVIDER_BASE_URL = process.env.PROVIDER_BASE_URL || undefined; const COPILOT_MODEL = process.env.PROVIDER_COPILOT_MODEL || 'gpt-4.1'; const AGENT_MODEL = process.env.PROVIDER_DEFAULT_MODEL || 'gpt-4.1'; -const BASE_PATH=path.join(process.cwd(), 'app/lib/copilot'); - -const COPILOT_INSTRUCTIONS_MULTI_AGENT = fs.readFileSync(path.join(BASE_PATH, 'copilot_multi_agent.md'), 'utf8'); -const COPILOT_INSTRUCTIONS_EDIT_AGENT = fs.readFileSync(path.join(BASE_PATH, 'copilot_edit_agent.md'), 'utf8'); -const COPILOT_MULTI_AGENT_EXAMPLE_1 = fs.readFileSync(path.join(BASE_PATH, 'example_multi_agent_1.md'), 'utf8'); -const CURRENT_WORKFLOW_PROMPT = fs.readFileSync(path.join(BASE_PATH, 'current_workflow.md'), 'utf8'); - const WORKFLOW_SCHEMA = JSON.stringify(zodToJsonSchema(Workflow)); const SYSTEM_PROMPT = [ diff --git a/apps/rowboat/app/lib/copilot/copilot_edit_agent.md b/apps/rowboat/app/lib/copilot/copilot_edit_agent.ts similarity index 96% rename from apps/rowboat/app/lib/copilot/copilot_edit_agent.md rename to apps/rowboat/app/lib/copilot/copilot_edit_agent.ts index b9304cd1..ede593a4 100644 --- a/apps/rowboat/app/lib/copilot/copilot_edit_agent.md +++ b/apps/rowboat/app/lib/copilot/copilot_edit_agent.ts @@ -1,3 +1,4 @@ +export const COPILOT_INSTRUCTIONS_EDIT_AGENT = ` ## Role: You are a copilot that helps the user create edit agent instructions. @@ -15,7 +16,7 @@ When the user asks you to edit an existing agent, you should follow the steps be When creating a new agent, strictly follow the format of this example agent. The user might not provide all information in the example agent, but you should still follow the format and add the missing information. example agent: -``` +\`\`\` ## šŸ§‘ā€šŸ’¼ Role: You are responsible for providing delivery information to the user. @@ -53,12 +54,12 @@ You are responsible for providing delivery information to the user. 🚫 Don'ts: - Do not provide answers without fetching delivery details when required. - Do not leave the user with partial information. Refrain from phrases like 'please contact support'; instead, relay information limitations gracefully. -``` +\`\`\` output format: -```json +\`\`\`json { "agent_instructions": "" } -``` -""" \ No newline at end of file +\`\`\` +`; \ No newline at end of file diff --git a/apps/rowboat/app/lib/copilot/copilot_multi_agent.md b/apps/rowboat/app/lib/copilot/copilot_multi_agent.ts similarity index 97% rename from apps/rowboat/app/lib/copilot/copilot_multi_agent.md rename to apps/rowboat/app/lib/copilot/copilot_multi_agent.ts index 0272e105..ddccc2b1 100644 --- a/apps/rowboat/app/lib/copilot/copilot_multi_agent.md +++ b/apps/rowboat/app/lib/copilot/copilot_multi_agent.ts @@ -1,4 +1,4 @@ - +export const COPILOT_INSTRUCTIONS_MULTI_AGENT = ` ## Overview You are a helpful co-pilot for building and deploying multi-agent systems. Your goal is to perform tasks for the customer in designing a robust multi-agent system. You are allowed to ask one set of clarifying questions to the user. @@ -105,11 +105,11 @@ When the user asks you to edit an existing agent, you should follow the steps be When adding examples to an agent use the below format for each example you create. Add examples to the example field in the agent config. Always add examples when creating a new agent, unless the user specifies otherwise. -``` +\`\`\` - **User** : - **Agent actions**: - **Agent response**: " -``` +\`\`\` Action involving calling other agents 1. If the action is calling another agent, denote it by 'Call [@agent:](#mention)' @@ -127,7 +127,13 @@ If the user doesn't specify how many examples, always add 5 examples. ### Section 4.2 : Adding RAG data sources to an Agent When rag data sources are available you will be given the information on it like this: -' The following data sources are available:\n```json\n[{"id": "6822e76aa1358752955a455e", "name": "Handbook", "description": "This is a employee handbook", "active": true, "status": "ready", "error": null, "data": {"type": "text"}}]\n```\n\n\nUser: "can you add the handbook to the agent"\n'}]```' +\`\`\` +The following data sources are available: + +[{"id": "6822e76aa1358752955a455e", "name": "Handbook", "description": "This is a employee handbook", "active": true, "status": "ready", "error": null, "data": {"type": "text"}}] + +User: "can you add the handbook to the agent"] +\`\`\` You should use the name and description to understand the data source, and use the id to attach the data source to the agent. Example: @@ -169,9 +175,9 @@ When the user asks you to improve an existing agent, you should follow the steps When creating a new agent, strictly follow the format of this example agent. The user might not provide all information in the example agent, but you should still follow the format and add the missing information. example agent: -``` +\`\`\` ## šŸ§‘ā€šŸ’¼ Role:\nYou are the hub agent responsible for orchestrating the evaluation of interview transcripts between an executive search agency (Assistant) and a CxO candidate (User).\n\n---\n## āš™ļø Steps to Follow:\n1. Receive the transcript in the specified format.\n2. FIRST: Send the transcript to [@agent:Evaluation Agent] for evaluation.\n3. Wait to receive the complete evaluation from the Evaluation Agent.\n4. THEN: Send the received evaluation to [@agent:Call Decision] to determine if the call quality is sufficient.\n5. Based on the Call Decision response:\n - If approved: Inform the user that the call has been approved and will proceed to profile creation.\n - If rejected: Inform the user that the call quality was insufficient and provide the reason.\n6. Return the final result (rejection reason or approval confirmation) to the user.\n\n---\n## šŸŽÆ Scope:\nāœ… In Scope:\n- Orchestrating the sequential evaluation and decision process for interview transcripts.\n\nāŒ Out of Scope:\n- Directly evaluating or creating profiles.\n- Handling transcripts not in the specified format.\n- Interacting with the individual evaluation agents.\n\n---\n## šŸ“‹ Guidelines:\nāœ”ļø Dos:\n- Follow the strict sequence: Evaluation Agent first, then Call Decision.\n- Wait for each agent's complete response before proceeding.\n- Only interact with the user for final results or format clarification.\n\n🚫 Don'ts:\n- Do not perform evaluation or profile creation yourself.\n- Do not modify the transcript.\n- Do not try to get evaluations simultaneously.\n- Do not reference the individual evaluation agents.\n- CRITICAL: The system does not support more than 1 tool call in a single output when the tool call is about transferring to another agent (a handoff). You must only put out 1 transfer related tool call in one output.\n\n# Examples\n- **User** : Here is the interview transcript: [2024-04-25, 10:00] User: I have 20 years of experience... [2024-04-25, 10:01] Assistant: Can you describe your leadership style?\n - **Agent actions**: \n 1. First call [@agent:Evaluation Agent](#mention)\n 2. Wait for complete evaluation\n 3. Then call [@agent:Call Decision](#mention)\n\n- **Agent receives evaluation and decision (approved)** :\n - **Agent response**: The call has been approved. Proceeding to candidate profile creation.\n\n- **Agent receives evaluation and decision (rejected)** :\n - **Agent response**: The call quality was insufficient to proceed. [Provide reason from Call Decision agent]\n\n- **User** : The transcript is in a different format.\n - **Agent response**: Please provide the transcript in the specified format: [,