You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 6, 2024. It is now read-only.
After going through multiple issues, I am still unclear about why the developers seem hesitant in supporting changes to the baseUrl. Is it because the repository is named "openai-java"? I am a bit confused and would appreciate some clarification.
If they won't change it, change it for them, like we did:
classSlashInterceptor(trueBase: String) extendsInterceptor:overridedefintercept(chain: Interceptor.Chain):Response=valoriginalRequest:Request= chain.request()
valoriginalUrl:HttpUrl= originalRequest.url()
// Check if the URL starts with an incorrect baseif!originalUrl.encodedPath().startsWith(trueBase) then// Replace the mismatched leading sectionvalnewUrl:HttpUrl= originalUrl
.newBuilder()
.encodedPath(trueBase +"/"+ originalUrl.encodedPath().substring(1))
.build()
// Create a new request with the modified URLvalnewRequest:Request= originalRequest
.newBuilder()
.url(newUrl)
.build()
// Proceed with the modified request
chain.proceed(newRequest)
else// Proceed with the original request
chain.proceed(originalRequest)
The above interceptor example can be trivially modified to change the .host(...) on the newRequest builder if you wish to alter the host section of the URI instead of simply prepending to the path. This is generally unnecessary, as the host redirection can occur at the retrofit level, as shown in the above Usage example.
Activity
dhallatmaine commentedon Nov 21, 2023
#418
ffrankan commentedon Nov 30, 2023
After going through multiple issues, I am still unclear about why the developers seem hesitant in supporting changes to the baseUrl. Is it because the repository is named "openai-java"? I am a bit confused and would appreciate some clarification.
Dessix commentedon Nov 30, 2023
If they won't change it, change it for them, like we did:
Usage:
The above interceptor example can be trivially modified to change the
.host(...)
on thenewRequest
builder if you wish to alter the host section of the URI instead of simply prepending to the path. This is generally unnecessary, as the host redirection can occur at the retrofit level, as shown in the above Usage example.