-
Notifications
You must be signed in to change notification settings - Fork 124
Add AI-powered search features #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
d73b322
Initial devcontainer setup
Strift 5ddb097
Use gradle inside devcontainer
Strift 45026c8
Add embedders settings
Strift 74ed1f2
Run spotless
Strift d47e0f6
Add hybrid parameter
Strift 426f605
Fix null embedder test
Strift a209989
Remove devcontainer
Strift 08a7684
Rename embedder and add EmbedderDistirbution class
Strift 2ba68af
Update embedders distribution test
Strift 807a2b6
Lint
Strift 6b4a620
Update test
Strift de3a46d
Temporarily add more info to tests
Strift 132e191
Remove document template edition
Strift 405a0e9
Update reset embedder test
Strift c52fc85
Update rest embedder test
Strift 5514722
Create RestEmbedder class
Strift 930aa39
Delete RestEmbedder class for consistency
Strift dc7ba8d
Remove error prones embedders
Strift b7b8506
Clean up tests
Strift 3c53bca
Lint
Strift 6bb3106
Add vector search test
Strift 9c76f88
Add hybrid
Strift 40fa243
Fix tasks test
Strift cefaf25
Add retrieveVectors
Strift 4306308
Spotless
Strift b8b3c88
Add check for optional _vectors
Strift 22482fb
Add tests for similar documents
Strift 3c93870
Merge branch 'main' into feat/add-ai-powered-search
Strift 35d1ec7
Update src/main/java/com/meilisearch/sdk/SearchRequest.java
Strift 93c73f5
Add javadoc
Strift 875d73d
Remove unnecessary test
Strift fc83d3d
Replace repetitive code by loop
Strift 44adc3f
Add comment on annotations
Strift b923f5e
id and embedder are not optional fields
Strift f873afe
Remove unnecessary tests
Strift af662a0
Lint
Strift 8cef5d3
Lint
Strift f084169
Lint
Strift 5e7a4d6
Merge branch 'main' into feat/add-ai-powered-search
Strift 75c7d74
Use createIndex instead of createEmptyIndex
Strift 10701ee
Remove comment
Strift 5a29190
lint
Strift b91b92b
Merge branch 'main' into feat/add-ai-powered-search
Strift 9272e76
Update tests to use empty index
Strift 1b24185
Merge branch 'main' into feat/add-ai-powered-search
Strift File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.meilisearch.sdk.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.util.Map; | ||
import lombok.*; | ||
import lombok.experimental.Accessors; | ||
|
||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PACKAGE) | ||
@Getter | ||
@Setter | ||
@Accessors(chain = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class Embedder { | ||
/** Source of the embedder. Accepts: ollama, rest, openAI, huggingFace and userProvided */ | ||
protected EmbedderSource source; | ||
|
||
/** | ||
* API key for authentication with the embedder service. Optional: Only applicable for openAi, | ||
* ollama, and rest sources. | ||
*/ | ||
protected String apiKey; | ||
|
||
/** | ||
* Model to use for generating embeddings. Optional: Only applicable for ollama, openAI, and | ||
* huggingFace sources. | ||
*/ | ||
protected String model; | ||
|
||
/** Template for document embedding. Optional. */ | ||
protected String documentTemplate; | ||
|
||
/** | ||
* Dimensions of the embedding vectors. Optional: Only applicable for openAi, huggingFace, | ||
* ollama, and rest sources. | ||
*/ | ||
protected Integer dimensions; | ||
|
||
/** Distribution configuration. Optional. */ | ||
protected EmbedderDistribution distribution; | ||
|
||
/** Request configuration. Mandatory only when using rest embedder, optional otherwise. */ | ||
protected Map<String, Object> request; | ||
|
||
/** Response configuration. Mandatory only when using rest embedder, optional otherwise. */ | ||
protected Map<String, Object> response; | ||
|
||
/** Maximum bytes for document template. Optional. */ | ||
protected Integer documentTemplateMaxBytes; | ||
|
||
/** Revision identifier. Optional: Only applicable for huggingFace. */ | ||
protected String revision; | ||
|
||
/** HTTP headers. Optional: Only applicable for rest. */ | ||
protected Map<String, String> headers; | ||
|
||
/** Whether to use binary quantization. Optional. */ | ||
protected Boolean binaryQuantized; | ||
|
||
/** URL for the embedder service. Optional. */ | ||
protected String url; | ||
|
||
/** Input fields for the embedder. Optional. */ | ||
protected String[] inputField; | ||
|
||
/** Type of input for the embedder. Optional. */ | ||
protected EmbedderInputType inputType; | ||
|
||
/** Query for the embedder. Optional. */ | ||
protected String query; | ||
|
||
public Embedder() {} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/com/meilisearch/sdk/model/EmbedderDistribution.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.meilisearch.sdk.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.Accessors; | ||
|
||
/** | ||
* Describes the natural distribution of search results for embedders. Contains mean and sigma | ||
* values, each between 0 and 1. | ||
*/ | ||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PACKAGE) | ||
@NoArgsConstructor(access = AccessLevel.PUBLIC) | ||
@Getter | ||
@Setter | ||
@Accessors(chain = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class EmbedderDistribution { | ||
/** Mean value of the distribution, between 0 and 1 */ | ||
private Double mean; | ||
|
||
/** Sigma (standard deviation) value of the distribution, between 0 and 1 */ | ||
private Double sigma; | ||
|
||
/** | ||
* Creates a uniform distribution with default values | ||
* | ||
* @return An EmbedderDistribution instance with mean=0.5 and sigma=0.5 | ||
*/ | ||
public static EmbedderDistribution uniform() { | ||
return new EmbedderDistribution().setMean(0.5).setSigma(0.5); | ||
} | ||
|
||
/** | ||
* Creates a custom distribution with specified mean and sigma values | ||
* | ||
* @param mean Mean value between 0 and 1 | ||
* @param sigma Sigma value between 0 and 1 | ||
* @return An EmbedderDistribution instance with the specified values | ||
* @throws IllegalArgumentException if mean or sigma are outside the valid range | ||
*/ | ||
public static EmbedderDistribution custom(double mean, double sigma) { | ||
if (mean < 0 || mean > 1) { | ||
throw new IllegalArgumentException("Mean must be between 0 and 1"); | ||
} | ||
if (sigma < 0 || sigma > 1) { | ||
throw new IllegalArgumentException("Sigma must be between 0 and 1"); | ||
} | ||
return new EmbedderDistribution().setMean(mean).setSigma(sigma); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.