Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.8.x] Add Assistant API #243

Merged
merged 44 commits into from
Nov 13, 2023
Merged

[0.8.x] Add Assistant API #243

merged 44 commits into from
Nov 13, 2023

Conversation

gehrisandro
Copy link
Collaborator

@gehrisandro gehrisandro commented Nov 7, 2023

@gehrisandro
Copy link
Collaborator Author

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');
  1. 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();
  1. 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.

@obaid
Copy link

obaid commented Nov 8, 2023

I would pick from variation 1 or 2.

@coreation
Copy link

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!

@TomasVotruba
Copy link

@gehrisandro Thanks for kicking of 👍 Already running your PR locally and trying it out 👏

@nunomaduro nunomaduro changed the title Add assistant api [7.x] Add Assistant API Nov 11, 2023
@gehrisandro gehrisandro changed the base branch from main to 0.8.x November 12, 2023 07:51
@gehrisandro gehrisandro changed the title [7.x] Add Assistant API [0.8.x] Add Assistant API Nov 12, 2023
@gehrisandro gehrisandro marked this pull request as ready for review November 13, 2023 10:56
@gehrisandro gehrisandro merged commit a169658 into 0.8.x Nov 13, 2023
16 checks passed
@TomasVotruba
Copy link

@gehrisandro 👏 👏 👏 Thank you

@gehrisandro
Copy link
Collaborator Author

@gehrisandro 👏 👏 👏 Thank you

You are welcome! And thanks for supporting me!

@coreation
Copy link

Nice work @gehrisandro !

@ThibautPV
Copy link

Good job @gehrisandro 👏

Thank you !

@xitude
Copy link

xitude commented Nov 13, 2023

Well done @gehrisandro 🎉

@heychazza
Copy link

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

@xitude
Copy link

xitude commented Nov 25, 2023

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"

@nunomaduro nunomaduro deleted the add-assistant-api branch November 25, 2023 09:31
@heychazza
Copy link

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?

@Holsta0822
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants