@@ -82,15 +82,24 @@ export async function POST(req: NextRequest) {
82
82
) {
83
83
console . log ( "Smart AI" , automation ) ;
84
84
85
- const smart_ai_message = await openai . chat . completions . create ( {
86
- model : "gpt-4o-mini" ,
87
- messages : [
88
- {
89
- role : "assistant" ,
90
- content : `${ automation . listener ?. prompt } : Keep responses under 2 sentences` ,
91
- } ,
92
- ] ,
93
- } ) ;
85
+ let smart_ai_message ;
86
+ try {
87
+ smart_ai_message = await openai . chat . completions . create ( {
88
+ model : "gpt-3.5-turbo" ,
89
+ messages : [
90
+ {
91
+ role : "assistant" ,
92
+ content : `${ automation . listener ?. prompt } : Keep responses under 2 sentences` ,
93
+ } ,
94
+ ] ,
95
+ } ) ;
96
+ } catch ( error ) {
97
+ console . error ( "OpenAI API error:" , error ) ;
98
+ return NextResponse . json (
99
+ { message : "Error generating AI response" } ,
100
+ { status : 500 }
101
+ ) ;
102
+ }
94
103
console . log ( "answers?" , smart_ai_message ) ;
95
104
96
105
if ( smart_ai_message . choices [ 0 ] . message . content ) {
@@ -204,15 +213,24 @@ export async function POST(req: NextRequest) {
204
213
automation . listener . listener === "SMARTAI" &&
205
214
automation . User ?. subscription ?. plan === "PRO"
206
215
) {
207
- const smart_ai_message = await openai . chat . completions . create ( {
208
- model : "gpt-4o-mini" ,
209
- messages : [
210
- {
211
- role : "assistant" ,
212
- content : `${ automation . listener ?. prompt } : keep responses under 2 sentences` ,
213
- } ,
214
- ] ,
215
- } ) ;
216
+ let smart_ai_message ;
217
+ try {
218
+ smart_ai_message = await openai . chat . completions . create ( {
219
+ model : "gpt-3.5-turbo" ,
220
+ messages : [
221
+ {
222
+ role : "assistant" ,
223
+ content : `${ automation . listener ?. prompt } : keep responses under 2 sentences` ,
224
+ } ,
225
+ ] ,
226
+ } ) ;
227
+ } catch ( error ) {
228
+ console . error ( "OpenAI API error:" , error ) ;
229
+ return NextResponse . json (
230
+ { message : "Error generating AI response" } ,
231
+ { status : 500 }
232
+ ) ;
233
+ }
216
234
console . log ( "answers?" , smart_ai_message ) ;
217
235
218
236
if ( smart_ai_message . choices [ 0 ] . message . content ) {
0 commit comments