Closed gehrisandro closed 8 months ago
The Assistant / Threads API has a nested structured and I am currently trying to figure out, how we should access the API. Here are lists of some of the endpoints in three different variations:
1) Nested Resources
$client->assistants()->create(parameters: [/* ... */]);
$client->assistants()->files()->retrieve(assistantId: 'asst_123', fileId: 'file_123');
$client->threads()->create(parameters: [/* ... */]);
$client->threads()->runs()->create(threadId: 'thread_123', parameters: [/* ... */]);
$client->threads()->runs()->submitToolOutputs(threadId: 'thread_123', runId: 'run_123', parameters: [/* ... */]);
$client->threads()->runs()->steps()->retrieve(threadId: 'thread_123', runId: 'run_123', stepId: 'step_123');
$client->threads()->runs()->steps()->list(threadId: 'thread_123', runId: 'run_123');
2) Nested Resources with ID parameters
$client->assistants()->create(parameters: [/* ... */]);
$client->assistant(assistantId: 'asst_123')->retrieve(fileId: 'file_123');
$client->threads()->create(parameters: [/* ... */]);
$client->thread(threadId: 'thread_123')->runs()->create(parameters: [/* ... */]);
$client->thread(threadId: 'thread_123')->run(runId: 'run_123')->submitToolOutputs(parameters: [/* ... */]);
$client->thread(threadId: 'thread_123')->run(runId: 'run_123')->steps()->retrieve(stepId: 'step_123');
$client->thread(threadId: 'thread_123')->run(runId: 'run_123')->steps()->list();
3) Sibling Resources
$client->assistants()->create(parameters: [/* ... */]);
$client->assistantFiles()->retrieve(assistantId: 'asst_123', fileId: 'file_123');
$client->threads()->create(parameters: [/* ... */]);
$client->threadRuns()->create(threadId: 'thread_123', parameters: [/* ... */]);
$client->threadRuns()->submitToolOutputs(threadId: 'thread_123', runId: 'run_123', parameters: [/* ... */]);
$client->threadRunSteps()->retrieve(threadId: 'thread_123', runId: 'run_123', stepId: 'step_123');
$client->threadRunSteps()->list(threadId: 'thread_123', runId: 'run_123');
@nunomaduro What do you think? ATM I would probably go for variation 1.
I would pick from variation 1 or 2.
I'd go for version 2 simply because of the "RESTful" approach of it. You define what resource you're working with as you chain the functions together. I wonder if there's a non-chaining approach so that you basically go for variation 1 but with a specific "fetch" function. I.e ...->fetchAssistantStep(threadId, runId, stepId) (or something in that nature).
Just my 2 cents, I haven't deep dived into the beta API just yet :) In any case, thanks so much for adding the feature!
@gehrisandro Thanks for kicking of :+1: Already running your PR locally and trying it out :clap:
@gehrisandro :clap: :clap: :clap: Thank you
@gehrisandro 👏 👏 👏 Thank you
You are welcome! And thanks for supporting me!
Nice work @gehrisandro !
Good job @gehrisandro 👏
Thank you !
Well done @gehrisandro 🎉
Thank you @gehrisandro, is it possible to upload the new API somehow? I see the docs show that you can, but don't see it in the PHP wrapper
Thank you @gehrisandro, is it possible to upload the new API somehow? I see the docs show that you can, but don't see it in the PHP wrapper
Can you explain by what you mean by "new API"
Thank you @gehrisandro, is it possible to upload the new API somehow? I see the docs show that you can, but don't see it in the PHP wrapper
Can you explain by what you mean by "new API"
Hey, sorry I meant - using the files API, how would we upload a file to OpenAI?
Is it possible to upload a temp file?
Thanks
https://platform.openai.com/docs/api-reference/assistants