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: [ messages: [
{ {
role: 'system', 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', role: 'user',
@ -57,7 +57,7 @@ async function main() {
messages: [ messages: [
{ {
role: 'system', 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', role: 'user',

Wyświetl plik

@ -15,7 +15,7 @@ async function main() {
messages: [ messages: [
{ {
role: 'system', 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', role: 'user',

Wyświetl plik

@ -8,6 +8,8 @@ async function main() {
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! }) const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
const agentic = new Agentic({ openai }) const agentic = new Agentic({ openai })
const topic = process.argv[2] || 'HF0 accelerator'
const res = await agentic const res = await agentic
.gpt4(`Summarize the latest news on {{topic}} using markdown.`) .gpt4(`Summarize the latest news on {{topic}} using markdown.`)
.tools([new SerpAPITool()]) .tools([new SerpAPITool()])
@ -16,13 +18,8 @@ async function main() {
topic: z.string() topic: z.string()
}) })
) )
.output(
z.object({
summary: z.string()
})
)
.call({ .call({
topic: 'HF0 accelerator' topic
}) })
console.log('\n\n\n' + res) 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({ const output = this.outputSchema.parse({
type: res.type, type: res.type,
title: res.title, title: res.title,
objects: res.objects.map((obj) => ({ objects: res.objects?.map(
...pick( (obj) =>
obj, ({
'type', ...pick(
'siteName', obj,
'author', 'type',
// 'authorUrl', 'siteName',
'pageUrl', 'author',
'date', // 'authorUrl',
// 'estimatedDate', 'pageUrl',
// 'humanLanguage', 'date',
'items', // 'estimatedDate',
'text' // 'humanLanguage',
) 'items',
// tags: obj.tags?.map((tag) => tag.label) 'text'
// images: obj.images?.map((image) => omit(image, 'diffbotUri')) )
})) // 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}"`) 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}"`) this._logger.info(output, `SerpAPI response for query "${query}"`)
return output return output
} }
} }