OpenAI icon indicating copy to clipboard operation
OpenAI copied to clipboard

perf: add a url parameter for chatsStream()

Open tisfeng opened this issue 1 year ago • 1 comments

What

Add a new publick API

    public func chatsStream(query: ChatQuery, url: URL, onResult: @escaping (Result<ChatStreamResult, Error>) -> Void, completion: ((Error?) -> Void)?) {
        performStreamingRequest(request: JSONRequest<ChatStreamResult>(body: query.makeStreamable(), url: url), onResult: onResult, completion: completion)
    }

Why

The current URL construction API is quite ugly and not convenient for supporting user-defined URLs, such as supporting non-HTTPS. I hope to use the API simply like this:

openAI.chatsStream(query: query, url:"http://localhost:11434/v1/chat/completions")

Affected Areas

None, just added a new API.

tisfeng avatar May 11 '24 13:05 tisfeng