cosmetics
This commit is contained in:
parent
f2bf60029b
commit
267b947c63
|
@ -10,30 +10,31 @@ import retrofit2.http.POST;
|
|||
import retrofit2.http.Path;
|
||||
|
||||
interface ChromaApi {
|
||||
|
||||
@GET("api/v1/collections/{collection_name}")
|
||||
@Headers({ "Content-Type: application/json" })
|
||||
@Headers({"Content-Type: application/json"})
|
||||
Call<Collection> collection(@Path("collection_name") String collectionName);
|
||||
|
||||
@POST("api/v1/collections")
|
||||
@Headers({ "Content-Type: application/json" })
|
||||
@Headers({"Content-Type: application/json"})
|
||||
Call<Collection> createCollection(@Body CreateCollectionRequest createCollectionRequest);
|
||||
|
||||
@POST("api/v1/collections/{collection_id}/add")
|
||||
@Headers({ "Content-Type: application/json" })
|
||||
@Headers({"Content-Type: application/json"})
|
||||
Call<Boolean> addEmbeddings(@Path("collection_id") String collectionId, @Body AddEmbeddingsRequest embedding);
|
||||
|
||||
@POST("api/v1/collections/{collection_id}/query")
|
||||
@Headers({ "Content-Type: application/json" })
|
||||
@Headers({"Content-Type: application/json"})
|
||||
Call<QueryResponse> queryCollection(@Path("collection_id") String collectionId, @Body QueryRequest queryRequest);
|
||||
|
||||
@POST("api/v1/collections/{collection_id}/delete")
|
||||
@Headers({ "Content-Type: application/json" })
|
||||
@Headers({"Content-Type: application/json"})
|
||||
Call<List<String>> deleteEmbeddings(
|
||||
@Path("collection_id") String collectionId,
|
||||
@Body DeleteEmbeddingsRequest embedding
|
||||
@Path("collection_id") String collectionId,
|
||||
@Body DeleteEmbeddingsRequest embedding
|
||||
);
|
||||
|
||||
@DELETE("api/v1/collections/{collection_name}")
|
||||
@Headers({ "Content-Type: application/json" })
|
||||
@Headers({"Content-Type: application/json"})
|
||||
Call<Collection> deleteCollection(@Path("collection_name") String collectionName);
|
||||
}
|
||||
|
|
|
@ -179,13 +179,13 @@ public class Utils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new string with a trailing '/' if the provided path does not end with '/'
|
||||
* Appends a trailing '/' if the provided URL does not end with '/'
|
||||
*
|
||||
* @param str String to check for trailing '/'
|
||||
* @return Same string if it already ends with '/' or a new string that ends with '/'
|
||||
* @param url URL to check for trailing '/'
|
||||
* @return Same URL if it already ends with '/' or a new URL with '/' appended
|
||||
*/
|
||||
public static String ensureTrailingForwardSlash(String str) {
|
||||
return str.endsWith("/") ? str : str + "/";
|
||||
public static String ensureTrailingForwardSlash(String url) {
|
||||
return url.endsWith("/") ? url : url + "/";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.langchain4j.model.huggingface;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import dev.langchain4j.internal.Utils;
|
||||
import dev.langchain4j.model.huggingface.client.EmbeddingRequest;
|
||||
import dev.langchain4j.model.huggingface.client.HuggingFaceClient;
|
||||
import dev.langchain4j.model.huggingface.client.TextGenerationRequest;
|
||||
|
@ -21,6 +20,8 @@ import static dev.langchain4j.internal.ValidationUtils.ensureNotBlank;
|
|||
|
||||
class DefaultHuggingFaceClient implements HuggingFaceClient {
|
||||
|
||||
private static final String BASE_URL = "https://api-inference.huggingface.co/";
|
||||
|
||||
private final HuggingFaceApi huggingFaceApi;
|
||||
private final String modelId;
|
||||
|
||||
|
@ -39,7 +40,7 @@ class DefaultHuggingFaceClient implements HuggingFaceClient {
|
|||
.create();
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Utils.ensureTrailingForwardSlash("https://api-inference.huggingface.co/"))
|
||||
.baseUrl(BASE_URL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build();
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
package dev.langchain4j.model.ovhai;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
import dev.langchain4j.data.embedding.Embedding;
|
||||
import dev.langchain4j.data.segment.TextSegment;
|
||||
import dev.langchain4j.model.embedding.EmbeddingModel;
|
||||
import dev.langchain4j.model.output.Response;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@EnabledIfEnvironmentVariable(named = "OVHAI_AI_API_KEY", matches = ".+")
|
||||
public class OvhAiEmbeddingModelIT {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
void should_embed() {
|
||||
|
||||
EmbeddingModel model = OvhAiEmbeddingModel
|
||||
.builder()
|
||||
.apiKey(System.getenv("OVHAI_AI_API_KEY"))
|
||||
|
@ -38,8 +39,8 @@ public class OvhAiEmbeddingModelIT {
|
|||
|
||||
@Test
|
||||
void should_embed_one_segment_with_bge_e5_model() {
|
||||
EmbeddingModel model = OvhAiEmbeddingModel
|
||||
.builder()
|
||||
|
||||
EmbeddingModel model = OvhAiEmbeddingModel.builder()
|
||||
.apiKey(System.getenv("OVHAI_AI_API_KEY"))
|
||||
.baseUrl("https://bge-base-en-v1-5.endpoints.kepler.ai.cloud.ovh.net")
|
||||
.logRequests(true)
|
||||
|
@ -60,8 +61,8 @@ public class OvhAiEmbeddingModelIT {
|
|||
|
||||
@Test
|
||||
void should_embed_multiple_segments_with_bge_e5_model() {
|
||||
EmbeddingModel model = OvhAiEmbeddingModel
|
||||
.builder()
|
||||
|
||||
EmbeddingModel model = OvhAiEmbeddingModel.builder()
|
||||
.apiKey(System.getenv("OVHAI_AI_API_KEY"))
|
||||
.baseUrl("https://bge-base-en-v1-5.endpoints.kepler.ai.cloud.ovh.net")
|
||||
.logRequests(true)
|
||||
|
@ -81,6 +82,5 @@ public class OvhAiEmbeddingModelIT {
|
|||
assertThat(response.content().get(1).vector()).hasSize(768);
|
||||
|
||||
assertThat(response.finishReason()).isNull();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import retrofit2.http.GET;
|
|||
import retrofit2.http.Path;
|
||||
|
||||
interface VespaQueryApi {
|
||||
|
||||
@GET("search/{query}")
|
||||
Call<QueryResponse> search(@Path(value = "query", encoded = true) String query);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.langchain4j.model.workersai.client;
|
||||
|
||||
import dev.langchain4j.internal.Utils;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
@ -41,7 +40,7 @@ public class WorkersAiClient {
|
|||
.build();
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Utils.ensureTrailingForwardSlash(BASE_URL))
|
||||
.baseUrl(BASE_URL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(JacksonConverterFactory.create())
|
||||
.build();
|
||||
|
|
Loading…
Reference in New Issue