Skip to content

Commit cf9683a

Browse files
committed
Added JSDoc documentation for embedding services
1 parent 80bcba5 commit cf9683a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
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+
*/
17
export interface IEmbeddingModel {
28
generate(text: string): Promise<number[] | null>;
39
}

ai-assistant/src/core/services/embeddings/minilml6.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)