2023-06-24 00:37:49 +00:00
import 'dotenv/config'
import { OpenAIClient } from 'openai-fetch'
import { z } from 'zod'
import { Agentic , ReplicateStableDiffusionTool } from '@/index'
async function main() {
2023-06-24 19:24:14 +00:00
const openai = new OpenAIClient ( { apiKey : process.env.OPENAI_API_KEY ! } )
2023-06-24 00:37:49 +00:00
const agentic = new Agentic ( { openai } )
const topic = process . argv [ 2 ] || 'san francisco'
const res = await agentic
. gpt4 (
2023-06-24 19:24:14 +00:00
( { numImages , topic } ) = >
` Generate ${ numImages } images of ${ topic } . Use prompts that are artistic and creative. The output should contain ${ numImages } markdown images with descriptions. `
2023-06-24 00:37:49 +00:00
)
. modelParams ( { temperature : 1.0 } )
. tools ( [ new ReplicateStableDiffusionTool ( ) ] )
. input (
z . object ( {
numImages : z.number ( ) . default ( 5 ) ,
topic : z.string ( )
} )
)
. call ( {
topic
} )
console . log ( ` \ n \ n \ n ${ res } \ n \ n \ n ` )
}
main ( )