MacPaw / OpenAI

Swift community driven package for OpenAI public API
MIT License
2k stars 327 forks source link

feat: WIP Assistants API, feedback requested #126

Open cdillard opened 10 months ago

cdillard commented 10 months ago

Is your feature request related to a problem? Please describe. Yeah, I'd like to be able to support the assistant features like threads, runs, and files with assistants API.

I have a PR to start to explore the possibilities here.

Six new API endpoints are exposed in the APIPath to support the assistants API.

    static let assistants = "/v1/assistants"
    static let threads = "/v1/threads"
    static let runs = "/v1/threads/THREAD_ID/runs"
    static let runRetrieve = "/v1/threads/THREAD_ID/runs/RUN_ID"
    static let threadsMessages = "/v1/threads/THREAD_ID/messages"
    static let files = "/v1/files"

The OpenAIProtocol is modified as follows: added


    func assistants(query: AssistantsQuery?, method: String, completion: @escaping (Result<AssistantsResult, Error>) -> Void)

    func threads(query: ThreadsQuery, completion: @escaping (Result<ThreadsResult, Error>) -> Void)

    func runs(threadId: String, query: RunsQuery, completion: @escaping (Result<RunsResult, Error>) -> Void)

    func runRetrieve(threadId: String, runId:String, completion: @escaping (Result<RunRetreiveResult, Error>) -> Void)

    func threadsMessages(threadId: String, before: String?, completion: @escaping (Result<ThreadsMessagesResult, Error>) -> Void)

    func threadsAddMessage(threadId: String, query: ThreadAddMessageQuery, completion: @escaping (Result<ThreadAddMessageResult, Error>) -> Void)

    func files(query: FilesQuery, completion: @escaping (Result<FilesResult, Error>) -> Void)

Assistants:

Tools can be passed to assistant creation.

Threads/Runs

Files

Example App:

A new demonstration of the assistants API and its requirements of the polling has been added to the Demo app.

Create Assistant createAssistant

Chat with Assistant in thread chatThread

List assistants listAssistants

Describe the solution you'd like Support for Assistants, Threads, Runs, Run Retrieval, Fetching messages from threads, and uploading files to OpenAI API.

ingvarus-bc commented 10 months ago

Awesome! 😍😍😍 Will make a code review shortly! Thanks for your impressive work! πŸ”₯πŸ”₯πŸ”₯ Let's make a PR into the main repository to be able to review everything, as you mentioned here, enable community cooperation in one place and use our CI pipeline? You can get acquainted with our Contribution Guidelines here. 😌

morad commented 10 months ago

Hello, I am excited by this new PR. Any status/update with it?

Let me know if I can be any help.

philippzagar commented 9 months ago

@cdillard Amazing work, let me know if I can be of any help!

cdillard commented 9 months ago

Opened PR: #140