我有这个代码
$data = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => 'Bearer '.env('OPENAI_API_KEY'),
])
->post("https://api.openai.com/v1/chat/completions", [
"model" => "gpt-3.5-turbo",
'messages' => [
[
"role" => "user",
"content" => $search
]
],
'temperature' => 0.5,
"max_tokens" => 200,
"top_p" => 1.0,
"frequency_penalty" => 0.52,
"presence_penalty" => 0.5,
"stop" => ["11."],
])
->json();
return response()->json($data['choices'][0]['message'], 200, array(), JSON_PRETTY_PRINT);
如何在Laravel数据库中只插入$data ['message']
先谢谢你了
echo $data ['message'];
1条答案
按热度按时间mnemlml81#
通过openai的API docs with a response你需要保存: