docs: send email upon completion in example

old-agentic-v1^2
Philipp Burckhardt 2023-06-16 15:43:32 -04:00
rodzic 21a41e23d4
commit b4ffc2baf8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A2C3BCA4F31D1DDD
1 zmienionych plików z 22 dodań i 3 usunięć

Wyświetl plik

@ -2,7 +2,12 @@ import { OpenAIClient } from '@agentic/openai-fetch'
import 'dotenv/config'
import { z } from 'zod'
import { Agentic, SerpAPITool, withHumanFeedback } from '@/index'
import {
Agentic,
NovuNotificationTool,
SerpAPITool,
withHumanFeedback
} from '@/index'
async function main() {
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
@ -43,7 +48,7 @@ async function main() {
metadata.feedback.type === 'selectN' &&
metadata.feedback.selected
) {
const answer = agentic
const answer = await agentic
.gpt4(
`Generate an answer to the following question: "{{question}}" from each of the following experts: {{#each experts}}
- {{this.name}}: {{this.bio}}
@ -67,7 +72,21 @@ async function main() {
question,
experts: metadata.feedback.selected
})
console.log(answer)
const message = answer.reduce((acc, { expert, answer }) => {
return `${acc}
${expert}: ${answer}`
}, '')
const notifier = new NovuNotificationTool()
await notifier.call({
name: 'send-email',
payload: {
subject: 'Experts have answered your question: ' + question,
message
},
to: [{ subscriberId: '123' }]
})
}
}