Skip to content
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

Add AI-powered search changes related to v1.10 #593

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion index_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ func TestIndex_UpdateSettingsEmbedders(t *testing.T) {
Embedders: map[string]Embedder{
"default": {
Source: "openAi",
ApiKey: "xxx",
APIKey: "xxx",
Model: "text-embedding-3-small",
DocumentTemplate: "A movie titled '{{doc.title}}'",
},
Expand Down Expand Up @@ -3452,6 +3452,47 @@ func TestIndex_UpdateSettingsEmbedders(t *testing.T) {
TaskUID: 1,
},
},
{
name: "TestIndexUpdateSettingsEmbeddersWithRestSource",
args: args{
newIndex: true,
UID: "newIndexUID",
client: meili,
request: Settings{
Embedders: map[string]Embedder{
"default": {
Source: "rest",
URL: "https://api.openai.com/v1/embeddings",
APIKey: "<your-openai-api-key>",
Dimensions: 1536,
DocumentTemplate: "A movie titled '{{doc.title}}' whose description starts with {{doc.overview|truncatewords: 20}}",
Distribution: &Distribution{
Mean: 0.7,
Sigma: 0.3,
},
Request: map[string]interface{}{
"model": "text-embedding-3-small",
"input": []string{"{{text}}", "{{..}}"},
},
Response: map[string]interface{}{
"data": []interface{}{
map[string]interface{}{
"embedding": "{{embedding}}",
},
"{{..}}",
},
},
Headers: map[string]string{
"Custom-Header": "CustomValue",
},
},
},
},
},
wantTask: &TaskInfo{
TaskUID: 1,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
24 changes: 18 additions & 6 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,25 @@ type Faceting struct {
SortFacetValuesBy map[string]SortFacetType `json:"sortFacetValuesBy"`
}

// Embedder represents a unified configuration for various embedder types.
type Embedder struct {
Source string `json:"source"`
URL string `json:"url,omitempty"`
ApiKey string `json:"apiKey,omitempty"`
Model string `json:"model,omitempty"`
Dimensions int `json:"dimensions,omitempty"`
DocumentTemplate string `json:"documentTemplate,omitempty"`
Source string `json:"source"` // The type of embedder: "openAi", "huggingFace", "userProvided", "rest", "ollama"
Model string `json:"model,omitempty"` // Optional for "openAi", "huggingFace", "ollama"
APIKey string `json:"apiKey,omitempty"` // Optional for "openAi", "rest", "ollama"
DocumentTemplate string `json:"documentTemplate,omitempty"` // Optional for most embedders
Dimensions int `json:"dimensions,omitempty"` // Optional for "openAi", "rest", "userProvided", "ollama"
Distribution *Distribution `json:"distribution,omitempty"` // Optional for all embedders
URL string `json:"url,omitempty"` // Optional for "openAi", "rest", "ollama"
Revision string `json:"revision,omitempty"` // Optional for "huggingFace"
Request map[string]interface{} `json:"request,omitempty"` // Optional for "rest"
Response map[string]interface{} `json:"response,omitempty"` // Optional for "rest"
Headers map[string]string `json:"headers,omitempty"` // Optional for "rest"
}

// Distribution represents a statistical distribution with mean and standard deviation (sigma).
type Distribution struct {
Mean float64 `json:"mean"` // Mean of the distribution
Sigma float64 `json:"sigma"` // Sigma (standard deviation) of the distribution
}

// Version is the type that represents the versions in meilisearch
Expand Down
Loading
Loading