File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,14 @@ BODY:
2727` ;
2828 // 👇 Adiciona aqui
2929 console . log ( '[DEBUG] OpenAI key starts with:' , process . env . OPENAI_API_KEY ?. slice ( 0 , 5 ) ) ;
30-
30+ console . log ( '[DEBUG] Sending prompt to OpenAI...' ) ;
31+ try {
3132 const response = await openai . chat . completions . create ( {
3233 model : 'gpt-4' ,
3334 messages : [ { role : 'user' , content : prompt } ] ,
3435 temperature : 0.4 ,
3536 } ) ;
36- // TODO(priority=high): improve retry logic for API errors
37+ // TODO(priority=high): improve retry logic for API errors
3738 const result = response . choices [ 0 ] . message ?. content || '' ;
3839 const match = result . match ( / T I T L E : \s * ( .+ ?) \s * B O D Y : \s * ( [ \s \S ] * ) / i) ;
3940
4344
4445 const [ , title , body ] = match ;
4546 return { title : title . trim ( ) , body : body . trim ( ) } ;
47+ } catch ( err : any ) {
48+ console . error ( '[ERROR] OpenAI call failed:' , err ) ;
49+ throw err ;
50+ }
4651}
52+
You can’t perform that action at this time.
0 commit comments