adamrushy / OpenAISwift

This is a wrapper library around the ChatGPT and OpenAI HTTP API
MIT License
1.62k stars 246 forks source link

Is it possible to control the progress of data connections on the user side? #76

Open usagimaru opened 1 year ago

usagimaru commented 1 year ago

I have a use-case where I want to utilize URLSessionDelegate to keep track of the progress of data connections in detail.

The current design of OpenAISwift.swift uses the dataTask(with:completionHandler:) method of URLSession to perform data communication, but this method seems to bypass the various callbacks of URLSessionDelegate to completion handler. (refs)

I tried using OpenAISwift.Config to specify my own URLSession, but in the end I could not get the URLSessionDelegate to work.

It would be nice if there was an interface that could support URLSessionDelegate (or its subprotocols), or an original callback mechanism that could keep track of the progress of data communication in detail.