Travis Fischer 2023-06-17 12:02:14 -07:00
rodzic c932ae50d1
commit c13a43e41b
5 zmienionych plików z 26 dodań i 27 usunięć

Wyświetl plik

@ -22,7 +22,7 @@ async function main() {
messages: [
{
role: 'system',
content: `You are a MckInsey analyst who is an expert at writing executive summaries.`
content: `You are a McKinsey analyst who is an expert at writing executive summaries.`
},
{
role: 'user',
@ -57,7 +57,7 @@ async function main() {
messages: [
{
role: 'system',
content: `You are a MckInsey analyst who is an expert at writing executive summaries.`
content: `You are a McKinsey analyst who is an expert at writing executive summaries.`
},
{
role: 'user',

Wyświetl plik

@ -15,7 +15,7 @@ async function main() {
messages: [
{
role: 'system',
content: `You are a MckInsey analyst who is an expert at writing executive summaries. Always respond using markdown unless instructed to respond using JSON.`
content: `You are a McKinsey analyst who is an expert at writing executive summaries. Always respond using markdown.`
},
{
role: 'user',

Wyświetl plik

@ -8,6 +8,8 @@ async function main() {
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
const agentic = new Agentic({ openai })
const topic = process.argv[2] || 'HF0 accelerator'
const res = await agentic
.gpt4(`Summarize the latest news on {{topic}} using markdown.`)
.tools([new SerpAPITool()])
@ -16,13 +18,8 @@ async function main() {
topic: z.string()
})
)
.output(
z.object({
summary: z.string()
})
)
.call({
topic: 'HF0 accelerator'
topic
})
console.log('\n\n\n' + res)

Wyświetl plik

@ -109,23 +109,26 @@ export class DiffbotTool extends BaseTask<DiffbotInput, DiffbotOutput> {
const output = this.outputSchema.parse({
type: res.type,
title: res.title,
objects: res.objects.map((obj) => ({
...pick(
obj,
'type',
'siteName',
'author',
// 'authorUrl',
'pageUrl',
'date',
// 'estimatedDate',
// 'humanLanguage',
'items',
'text'
)
// tags: obj.tags?.map((tag) => tag.label)
// images: obj.images?.map((image) => omit(image, 'diffbotUri'))
}))
objects: res.objects?.map(
(obj) =>
({
...pick(
obj,
'type',
'siteName',
'author',
// 'authorUrl',
'pageUrl',
'date',
// 'estimatedDate',
// 'humanLanguage',
'items',
'text'
)
// tags: obj.tags?.map((tag) => tag.label)
// images: obj.images?.map((image) => omit(image, 'diffbotUri'))
} || [])
)
})
this._logger.info(output, `Diffbot response for url "${ctx.input!.url}"`)

Wyświetl plik

@ -123,7 +123,6 @@ export class SerpAPITool extends BaseTask<SerpAPIInput, SerpAPIOutput> {
})
this._logger.info(output, `SerpAPI response for query "${query}"`)
return output
}
}