Created
January 24, 2024 08:19
-
-
Save homanp/31dc2f20e8a3003d47ef58970697107c to your computer and use it in GitHub Desktop.
Reference collector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SuperAgentClient } from "superagentai-js"; | |
const client = new SuperAgentClient({ | |
token: process.env["SUPERAGENT_API_KEY"], | |
environment: "https://api.beta.superagent.sh", | |
}); | |
async function createAgent(name, description, llmModel, prompt, isActive) { | |
return client.agent.create({ | |
name, | |
description, | |
llmModel, | |
prompt, | |
isActive, | |
}); | |
} | |
async function main() { | |
const agentPromises = [ | |
createAgent( | |
"Reference collector", | |
"A reference collector agent", | |
"GPT_4_1106_PREVIEW", | |
`You are chatting with a candidate named Jane Doe. Your job is to gather contact information for reference checks. Only return the specified info in the specified format. | |
ALLOWED FORMAT: {candidate, reference: {}}`, | |
true | |
), | |
createAgent( | |
"Email Writer", | |
"An email writer", | |
"GPT_4_1106_PREVIEW", | |
`You are a helpful AI Assistant that's an expert at doing reference checks for hiring. | |
Your task is to write an email on behalf of Commit.dev to a reference for a software dev job at Apple Inc. | |
Be personal and as human-like as possible. | |
FORMAT: { url: "https://api.resend.com/emails", method: "POST", body: { "from": "Gregg Gunn <[email protected]>", "to": ["<email addresses>"], "subject": "<email subject>", "text": "<email body>" } }`, | |
true | |
), | |
createAgent( | |
"Email Sender", | |
"An email sender", | |
"GPT_4_1106_PREVIEW", | |
"Use the input to send an email using the Email API.", | |
true | |
), | |
]; | |
const [referenceCollector, emailWriter, emailSender] = (await Promise.all(agentPromises)).map(result => result.data); | |
const { data: tool } = await client.tool.create({ | |
type: "HTTP", | |
name: "Email API", | |
description: "Useful for sending emails.", | |
metadata: { | |
headers: { | |
authorization: `Bearer ${process.env["RESEND_API_KEY"]}`, | |
}, | |
}, | |
returnDirect: false, | |
}); | |
await client.agent.addTool(emailSender.id, { toolId: tool.id }); | |
const { data: workflow } = await client.workflow.create({ | |
name: "Assistant workflow", | |
description: "Commit.dev reference checks.", | |
}); | |
const workflowSteps = [ | |
{ agentId: referenceCollector.id, order: 0 }, | |
{ agentId: emailWriter.id, order: 1 }, | |
{ agentId: emailSender.id, order: 2 }, | |
]; | |
for (const step of workflowSteps) { | |
await client.workflow.addStep(workflow.id, step); | |
} | |
console.log(workflow); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment