Open bobbingwide opened 4 months ago
The minimum code to demonstrate the problem.
I created a subfolder called tests
with a file called assistant.php
Source code of assistant.php
with apiKey and assistant_id obfuscated.
<?php
/**
* Simple test of the Assistant API
*
*/
require '../vendor/autoload.php';
$client = OpenAI::client( 'sk-obfuscated' );
//print_r( $client );
$response = $client->threads()->createAndRun(
[ 'assistant_id' => 'asst_obfuscated',
'thread' => [
'messages' =>
[ 'role' => 'user',
'content' => 'what time is 1706918400'
]
]
]
);
When I run "php assistant.php" I get
Fatal error: Uncaught OpenAI\Exceptions\ErrorException: 1 validation error for Request
body -> thread -> messages
value is not a valid list (type=type_error.list) in C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Transporters\HttpTransporter.php:133
Stack trace:
#0 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Transporters\HttpTransporter.php(57): OpenAI\Transporters\HttpTransporter->throwIfJsonError(Array, '{\n "error": {\n...')
#1 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Resources\Threads.php(51): OpenAI\Transporters\HttpTransporter->requestObject(Object(OpenAI\ValueObjects\Transporter\Payload))
#2 C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\tests\assistant.php(9): OpenAI\Resources\Threads->createAndRun(Array)
#3 {main}
thrown in C:\apache\htdocs\wordpress\wp-content\plugins\oik-ai\vendor\openai-php\client\src\Transporters\HttpTransporter.php on line 133
Description
I'm trying to use Assistants and Threads in order to benefit from the Code interpreter functionality. Unfortunately I've failed at the second hurdle - using CreateAndRun The first was realising that I didn't need to create an Assistant for each request.
My call is basically straight out of the book.
where
$this->assistant_id
is the ID of an assistant I've created either manually in OpenAI or using the API. An exception is produced but I do not know what to do to fix it.Stack trace:
I do understand this could be a question for the OpenAI Community forum.
Someone's having a similar problem, well a similar message, at https://community.openai.com/t/api-calls-to-v1-threads-thread-id-messages-fails-with-file-and-file-ids/613781
The problem that I am trying to resolve by using Assistants is documented in https://github.com/bobbingwide/oik-ai/issues/10 thanks in advance for any help, Herb
PS. The answer that I'm hoping to get is along the lines of "The timestamp 1706918400 corresponds to the date and time 2024-02-03 00:00:00 UTC."
Steps To Reproduce
OpenAI PHP Client Version
v0.8.4
PHP Version
8.3.0
Notes
Sorry, but I haven't yet created the minimum code to demonstrate this problem. I'm hoping someone's experienced something similar and can explain the error message.