Package org.machanism.machai.bindex
Class Picker
java.lang.Object
org.machanism.machai.bindex.Picker
Performs Bindex registration, lookup, and semantic retrieval using embeddings
and MongoDB.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPicker(com.mongodb.client.MongoCollection<org.bson.Document> collection, org.machanism.machai.ai.provider.Genai provider) Creates a picker with explicit dependencies.Picker(String genai, String uri, Configurator config) Creates a picker backed by the configured Bindex repository and a named GenAI provider. -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddDependencies(Set<String> dependencies, String bindexId) Recursively adds the dependencies of the given Bindex to the provided set.Registers or replaces a Bindex entry in the repository.protected BindexRetrieves a Bindex by its logical identifier.(package private) org.bson.BsonArraygetEmbeddingBson(Classification classification, int dimensions) Generates the BSON array representation of the embedding for a classification.(package private) static StringgetNormalizedLanguageName(Language language) Normalizes a language name for repository matching.getRegistredId(Bindex bindex) Finds the MongoDB registration identifier for the supplied Bindex.Returns the last recorded score for a Bindex identifier.Picks matching Bindex entries for a natural-language query.voidSets the minimum vector-search score accepted by this picker.
-
Field Details
-
BINDEX_PROPERTY_NAME
- See Also:
-
MODEL_PROP_NAME
- See Also:
-
SCORE_PROP_NAME
- See Also:
-
DEFAULT_SCORE_VALUE
-
-
Constructor Details
-
Picker
Creates a picker backed by the configured Bindex repository and a named GenAI provider.- Parameters:
genai- the provider identifier used to resolve the GenAI implementationuri- the repository URIconfig- the project configuration used for repository and prompt settings
-
Picker
Picker(com.mongodb.client.MongoCollection<org.bson.Document> collection, org.machanism.machai.ai.provider.Genai provider) Creates a picker with explicit dependencies.- Parameters:
collection- the MongoDB collection used to store and query Bindex documentsprovider- the GenAI provider used for prompt execution and embeddings
-
-
Method Details
-
create
Registers or replaces a Bindex entry in the repository.- Parameters:
bindex- the Bindex definition to persist- Returns:
- the inserted MongoDB identifier as a string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if the Bindex or its classification cannot be serialized
-
getEmbeddingBson
org.bson.BsonArray getEmbeddingBson(Classification classification, int dimensions) throws com.fasterxml.jackson.core.JsonProcessingException Generates the BSON array representation of the embedding for a classification.- Parameters:
classification- the classification to embeddimensions- the embedding dimensions requested from the provider- Returns:
- the embedding encoded as a BSON array
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if the classification cannot be serialized
-
getRegistredId
Finds the MongoDB registration identifier for the supplied Bindex.- Parameters:
bindex- the Bindex to look up- Returns:
- the MongoDB object identifier string, or
nullif not found
-
pick
Picks matching Bindex entries for a natural-language query.- Parameters:
query- the user request to classify and resolve- Returns:
- the list of matching Bindex entries
- Throws:
IOException- if classification generation or JSON parsing fails
-
addDependencies
Recursively adds the dependencies of the given Bindex to the provided set.- Parameters:
dependencies- the target set that accumulates dependency identifiersbindexId- the root Bindex identifier whose dependency graph is traversed
-
getBindex
Retrieves a Bindex by its logical identifier.- Parameters:
id- the Bindex identifier- Returns:
- the deserialized Bindex, or
nullif no entry exists
-
getNormalizedLanguageName
Normalizes a language name for repository matching.- Parameters:
language- the language to normalize- Returns:
- the normalized lowercase language name without any parenthetical suffix
-
setScore
Sets the minimum vector-search score accepted by this picker.- Parameters:
minScore- the minimum score threshold
-
getScore
Returns the last recorded score for a Bindex identifier.- Parameters:
id- the Bindex identifier- Returns:
- the recorded score, or
nullif none is available
-