@@ -32,8 +32,7 @@ app.get('/', (req, res) => {
3232app . post ( '/generate-logo' , async ( req , res ) => {
3333 const description = req . body . description ;
3434 const artists = getArtistsData ( ) ;
35- const prompt = `
36- tools: ./tool.gpt
35+ const instructions = `
3736 For each of the three amazing and capable artists described here
3837 ${ JSON . stringify ( artists ) }
3938 make sure to include the artistName field in the response.
@@ -51,8 +50,14 @@ app.post('/generate-logo', async (req, res) => {
5150 }]
5251 }
5352` ;
53+ const tool = new gptscript . Tool ( {
54+ tools : [ 'github.com/gptscript-ai/image-generation' ] ,
55+ jsonResponse : true ,
56+ instructions : instructions ,
57+ } )
58+
5459 try {
55- const output = await gptscript . exec ( prompt ) ;
60+ const output = await gptscript . exec ( tool ) ;
5661 const cleanedResp = output . trim ( ) . replace ( / ^ ` ` ` j s o n .* / , '' ) . replace ( / ` ` ` / g, '' ) ;
5762 res . json ( JSON . parse ( cleanedResp ) ) ;
5863 } catch ( error ) {
@@ -63,9 +68,7 @@ app.post('/generate-logo', async (req, res) => {
6368
6469// Route to request new artists
6570app . post ( '/new-artists' , async ( req , res ) => {
66- const prompt = `
67- tools: sys.write
68-
71+ const instructions = `
6972Create three short graphic artist descriptions and their muses.
7073These should be descriptive and explain their point of view.
7174Also come up with a made up name, they each should be from different
@@ -80,8 +83,14 @@ the response format should be json and MUST NOT have other content or formatting
8083 }]
8184}
8285` ;
86+ const tool = new gptscript . Tool ( {
87+ tools : [ 'sys.write' ] ,
88+ jsonResponse : true ,
89+ instructions : instructions ,
90+ } ) ;
91+
8392 try {
84- const output = await gptscript . exec ( prompt ) ;
93+ const output = await gptscript . exec ( tool ) ;
8594 const cleanedResp = output . trim ( ) . replace ( / ^ ` ` ` j s o n .* / , '' ) . replace ( / ` ` ` / g, '' ) ;
8695 newArtistsData = JSON . parse ( cleanedResp ) ;
8796 res . json ( newArtistsData ) ;
0 commit comments