org.devlive.sdk.openai.utils.HttpUrlUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openai-java-sdk Show documentation
Show all versions of openai-java-sdk Show documentation
Provides an easy-to-use SDK for Java developers to interact with the APIs of open AI models.
package org.devlive.sdk.openai.utils;
import okhttp3.HttpUrl;
import java.util.List;
public class HttpUrlUtils
{
private HttpUrlUtils()
{}
/**
* Removes all path segments from the given HttpUrl.
*
* @param httpUrl the HttpUrl from which to remove path segments
* @return the modified HttpUrl with all path segments removed
*/
public static HttpUrl removePathSegment(HttpUrl httpUrl)
{
List pathSegments = httpUrl.pathSegments();
for (int i = 0; i < pathSegments.size(); i++) {
httpUrl = httpUrl.newBuilder()
.removePathSegment(0)
.build();
}
return httpUrl;
}
}