Я могу создать ветку и получить доступ к помощнику, но мое добавление функции сообщения выдает следующий результат:
Array (
[error] => Array
(
[ message] => Отсутствует обязательный параметр: 'assistant_id'.
[type] => valid_request_error
[param] => Assistant_id
Код: Выделить всё
=> Missing_required_parameter
)
Есть идеи, как обойти это или обойти
[code]function addMessageToThread($assistant_id, $thread_id, $user_input, $api_key) {
$url = 'https://api.openai.com/v1/threads/' . $thread_id . '/messages';
$data = [
'assistant_id' => $assistant_id,
'role' => 'user',
'content' => [
'type' => 'text',
'text' => $user_input,
],
];
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $api_key,
'OpenAI-Beta: assistants=v2'
];
error_log('Message Data: ' . json_encode($data));
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if ($response === false) {
echo 'Request Error: ' . curl_error($ch);
curl_close($ch);
return null;
}
curl_close($ch);
return json_decode($response, true);
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... -parameter