Custom http headers
What
This pull request adds the ability to specify custom HTTP headers when integrating with OpenAI via proxy APIs such as Helicone. It also refactors OpenAi's performRequest() by encapsulating the logic for handling the session data task in its own class, URLSessionDataTaskManager. This should simplify the OpenAI class and make the code easier to manage. This pull request simplifies JSONRequest and MultipartFormDataRequest by abstracting out common code to remove repetition that previously existed in these structs. Finally, it simplifies the protocol URLRequestBuildable, moving configuration-driven parameter setting to the constructors of these struct instances, rather than in the call to that protocol's build() function.
Why
The motivation for this change was to allow users to integrate with OpenAI via the Helicone proxy. To do so, they not only need to point the OpenAI client at the Helicone host, but they also have to set an additional HTTP header on the requests. This pull request makes that possible.
Affected Areas
The affected areas of the library include:
- The OpenAI class within the OpenAI.swift file.
- The client configuration within the constructor of the OpenAI class.
- The construction of requests in the following methods: completions(), completionsStream(), images(), embeddings(), chats(), chatsStream(), edits(), model(), models(), moderations(), audioTranscriptions(), and audioTranslations().
Kudos, SonarCloud Quality Gate passed! 
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
Hi! Is there anything more I need to do in order to get this merged?
Hey, @benvolioT! Thanks a lot for the contribution! Please fix build and merge conflicts 🙏
Quality Gate passed
Issues
3 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code