OpenAI
OpenAI copied to clipboard
feat(basePath): enable base path for configuration
What
This MR is to resolve the issue https://github.com/MacPaw/OpenAI/issues/68#issuecomment-1548221958
Why
When we set up a proxy for OpenAI API, sometimes we enable a custom endpoint for it, so enabling a base path for the configuration would be helpful when we have something like 'my.host.com/openai/api' proxying OpenAI API.
Affected Areas
Configuration to initialize the OpenAI API instance but it's backward compatible.
Let's improve paths logic 🙏
Done refactoring and unit tests added.
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
9 Code Smells
No Coverage information
0.0% Duplication
The functionality of this PR is needed, but it seems like Merge is stuck @metrue @Krivoblotsky
Hey, everyone! Thanks a lot for the contribution, I'll review the next batch of PRs today (including this one) and publish a new release.
Also, I need to check why the build is failing ⚠️
Hey, everyone! Thanks a lot for the contribution, I'll review the next batch of PRs today (including this one) and publish a new release.
Cool, thanks so much 🙏
Hey, @metrue. Could you please fix the build? 🙏
hey @Krivoblotsky
I checked the CI log, it does tell why it failed,
2023-06-20T16:21:08.9885513Z Build complete! (4.18s)
2023-06-20T16:21:09.5590135Z error: Exited with signal code 4
2023-06-20T16:21:09.5631060Z Test Suite 'All tests' started at 2023-06-20 16:21:09.008
2023-06-20T16:21:09.5631973Z Test Suite 'debug.xctest' started at 2023-06-20 16:21:09.317
2023-06-20T16:21:09.5632912Z Test Suite 'OpenAITests' started at 2023-06-20 16:21:09.317
2023-06-20T16:21:09.5633428Z Test Case 'OpenAITests.testAudioTranscriptions' started at 2023-06-20 16:21:09.317
2023-06-20T16:21:09.5698541Z ##[error]Process completed with exit code 1.
2023-06-20T16:21:09.5791394Z Post job cleanup.
2023-06-20T16:21:09.7007792Z [command]/usr/bin/git version
And I run swift test
locally, it works well, anyone can advice would be great.
Test Case '-[OpenAITests.OpenAITestsDecoder testModerations]' started.
Test Case '-[OpenAITests.OpenAITestsDecoder testModerations]' passed (0.000 seconds).
Test Suite 'OpenAITestsDecoder' passed at 2023-08-23 22:47:56.335.
Executed 10 tests, with 0 failures (0 unexpected) in 0.003 (0.003) seconds
Test Suite 'OpenAIPackageTests.xctest' passed at 2023-08-23 22:47:56.335.
Executed 46 tests, with 0 failures (0 unexpected) in 0.029 (0.030) seconds
Test Suite 'All tests' passed at 2023-08-23 22:47:56.335.
Executed 46 tests, with 0 failures (0 unexpected) in 0.029 (0.033) seconds
@metrue, thanks! CI runs build and test on Linux, maybe this is the cause. I'll try to run it once again and check.
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
8 Code Smells
No Coverage information
0.0% Duplication
Hi, how is this PR coming along? Customizing the endpoints is necessary and I'm looking forward to this feature.
Going a step further, we can customize the entire endpoint, not just the base path, because sometimes we build the OpenAI service locally, when it's an http
request instead of an https
, e.g. http://localhost:3000/v1/chat/completions
Therefore, I hope to provide an endPoint
property that allows the user to freely configure the request URL.
I need this
Hi, how's this going?
还没搞定吗?
Quality Gate passed
Issues
8 New issues
Measures
0 Security Hotspots
No data about Coverage
1.3% Duplication on New Code
Due to the lack of developers handling this issue, I added a new public API myself to make it easier to support user-defined request URLs, just for my own convenience, and also submitted a PR https://github.com/MacPaw/OpenAI/pull/204 .
Can be used simply as follows:
openAI.chatsStream(query: query, url:"http://localhost:11434/v1/chat/completions")