@@ -10,7 +10,7 @@ import Actions from '@cocreate/actions'
1010// console.log('test', apifromCrud)
1111const apiKey = localStorage . getItem ( 'openAiKey' ) ;
1212const apiUrl = 'https://api.openai.com/v1/chat/completions' ;
13- const model = 'gpt-3.5-turbo '
13+ const model = 'gpt-4-1106-preview '
1414const max_tokens = 3300 ;
1515const temperature = 0.6 ;
1616const n = 1 ;
@@ -84,11 +84,15 @@ async function send(conversation) {
8484 } )
8585
8686 if ( data ) {
87- const content = data . chat . choices [ 0 ] . message . content ;
88- console . log ( content )
87+ let content = data . chat . choices [ 0 ] . message . content ;
88+ content = content . replace ( / ` ` ` j s o n \n | \n ` ` ` / g, '' ) ;
89+ content = JSON . parse ( content )
8990 let responseElement = document . querySelector ( '[openai="response"]' )
90- if ( responseElement )
91- responseElement . setValue ( content )
91+ if ( responseElement ) {
92+ let preValue = responseElement . getValue ( )
93+ let newValue = [ ...content , ...preValue ]
94+ responseElement . setValue ( newValue )
95+ }
9296 }
9397
9498 // const object = extractObjectFromCode(content);
@@ -213,8 +217,21 @@ async function openaiAction(form) {
213217 if ( ! [ 'system' , 'user' , 'assistant' ] . includes ( role ) )
214218 continue
215219 let content = await element . getValue ( )
220+ if ( ! content )
221+ continue
222+
223+ if ( element . getAttribute ( 'key' ) === 'careers' ) {
224+ let Content = [ ]
225+ if ( typeof content === 'string' )
226+ content = JSON . parse ( content )
227+ for ( let contentItem of content )
228+ Content . push ( contentItem . name )
229+ content = { previousCareers : Content }
230+ }
231+
216232 if ( typeof content === 'string' )
217233 conversation . push ( { role, content } )
234+
218235 // if (Array.isArray(content))
219236 // conversation.push({ role, content })
220237 if ( typeof content === 'object' ) {
0 commit comments