Skip to main content

Create Store

The CreateStore request creates a new AI store with specified AI models.

  • Input: Store name, query model, index model, optional predicates, and configuration flags.

  • Behavior: Creates a new AI store that automatically generates embeddings using the specified models.

  • Response: Confirmation of store creation.

Click to expand source code
import { createAiClient } from "ahnlich-client-node";
import { CreateStore } from "ahnlich-client-node/grpc/ai/query_pb";
import { AIModel } from "ahnlich-client-node/grpc/ai/models_pb";

async function createStore() {
const client = createAiClient("127.0.0.1:1370");

await client.createStore(
new CreateStore({
store: "ai_store",
queryModel: AIModel.ALL_MINI_LM_L6_V2,
indexModel: AIModel.ALL_MINI_LM_L6_V2,
predicates: ["brand", "category"],
errorIfExists: true,
storeOriginal: true,
})
);

console.log("AI store created successfully");
}

createStore();

Parameters​

ParameterTypeRequiredDescription
storestringYesThe name for the new AI store
queryModelAIModelYesAI model for embedding queries
indexModelAIModelYesAI model for embedding stored data
predicatesstring[]NoList of predicate keys to index
errorIfExistsbooleanNoIf true, throws error if store exists
storeOriginalbooleanNoIf true, stores original input alongside embeddings

Available AI Models​

ModelTypeDescription
AIModel.ALL_MINI_LM_L6_V2TextSentence transformer for text embeddings
AIModel.RESNET50ImageImage classification and embeddings
AIModel.CLIP_VIT_B32MultimodalText and image embeddings
AIModel.BUFFALO_LFaceFace detection and recognition
AIModel.SFACE_YUNETFaceFace detection with YuNet

Example with Image Model​

Click to expand source code
import { createAiClient } from "ahnlich-client-node";
import { CreateStore } from "ahnlich-client-node/grpc/ai/query_pb";
import { AIModel } from "ahnlich-client-node/grpc/ai/models_pb";

async function createImageStore() {
const client = createAiClient("127.0.0.1:1370");

await client.createStore(
new CreateStore({
store: "image_store",
queryModel: AIModel.RESNET50,
indexModel: AIModel.RESNET50,
predicates: ["filename", "category"],
errorIfExists: true,
storeOriginal: true,
})
);

console.log("Image store created successfully");
}

createImageStore();

Notes​

  • The query and index models typically should be the same for consistent similarity
  • storeOriginal: true is useful for retrieving the original text/image in results
  • See Type Meanings for more details on AI models