File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed
Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change 1- import { NextResponse } from 'next/server' ;
2- import { GoogleGenerativeAI } from '@google/generative-ai' ;
3-
1+ import { NextResponse } from "next/server" ;
2+ import { GoogleGenerativeAI } from "@google/generative-ai" ;
43
54const genAI = new GoogleGenerativeAI ( process . env . API_KEY ) ;
65
76export async function POST ( request ) {
87 const { message } = await request . json ( ) ;
98
10-
119 if ( ! message ) {
1210 return NextResponse . json (
1311 { error : "メッセージがありません。" } ,
@@ -17,19 +15,17 @@ export async function POST(request) {
1715
1816 try {
1917 const model = genAI . getGenerativeModel ( { model : "gemini-1.5-flash" } ) ;
20-
18+
2119 const result = await model . generateContent ( message ) ;
2220 const response = result . response ;
2321 const text = response . text ( ) ;
2422
2523 return NextResponse . json ( { response : text } ) ;
26-
2724 } catch ( e ) {
28-
2925 console . error ( "Error:" , e ) ;
3026 return NextResponse . json (
3127 { response : "エラーが発生しました。" } ,
3228 { status : 500 }
3329 ) ;
3430 }
35- }
31+ }
You can’t perform that action at this time.
0 commit comments