File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
ai-assistant/src/core/services/embeddings Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Generates an embedding for the given text.
3+ *
4+ * @param text - The input text for which the embedding needs to be generated.
5+ * @returns A promise that resolves to a 1D array of numbers representing the embedding of the text, or null if the embedding cannot be generated.
6+ */
17export interface IEmbeddingModel {
28 generate ( text : string ) : Promise < number [ ] | null > ;
39}
Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ export class MiniLML6 implements IEmbeddingModel {
1111 this . http = http ;
1212 }
1313
14+ /**
15+ * Extracts embeddings from Hugging Face API using the MiniLM-L6 model.
16+ * @param text - The input text to extract embeddings from.
17+ * @returns A promise that resolves to an array of numbers representing the embeddings, or null if the request fails.
18+ */
1419 async fromHuggingFace ( text : string ) : Promise < number [ ] | null > {
1520 const res = await this . http . post (
1621 `https://api-inference.huggingface.co/pipeline/feature-extraction/sentence-transformers/all-MiniLM-L6-v2` ,
@@ -34,6 +39,11 @@ export class MiniLML6 implements IEmbeddingModel {
3439 return data ;
3540 }
3641
42+ /**
43+ * Generates embeddings for the given text.
44+ * @param text - The input text for which embeddings need to be generated.
45+ * @returns A promise that resolves to an array of numbers representing the embeddings for the text, or null if the generation fails.
46+ */
3747 async generate ( text : string ) : Promise < number [ ] | null > {
3848 // return await this.fromHuggingFace(text);
3949
You can’t perform that action at this time.
0 commit comments