File size: 2,581 Bytes
fea62df
 
 
 
 
 
 
0231daa
fea62df
 
 
 
 
0231daa
fea62df
 
 
 
0231daa
fea62df
 
 
0231daa
fea62df
 
 
 
 
0231daa
fea62df
 
 
 
0231daa
fea62df
 
 
0231daa
fea62df
 
 
 
 
 
0231daa
fea62df
 
 
 
 
0231daa
fea62df
 
 
0231daa
fea62df
 
 
 
 
 
0231daa
fea62df
 
 
 
 
0231daa
fea62df
 
 
0231daa
fea62df
 
 
 
 
0231daa
fea62df
 
 
 
0231daa
fea62df
 
 
 
 
 
 
 
 
0231daa
fea62df
 
 
 
0231daa
fea62df
 
 
 
 
 
 
 
0231daa
fea62df
 
0231daa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from typing import List, Optional
from pydantic import BaseModel


class EmbedRequest(BaseModel):
    """
    Request model for single text embedding.

    Attributes:
        text: The input text to embed
        model_id: Identifier of the model to use
        prompt: Optional prompt for instruction-based models
    """

    text: str
    model_id: str
    prompt: Optional[str] = None


class BatchEmbedRequest(BaseModel):
    """
    Request model for batch text embedding.

    Attributes:
        texts: List of input texts to embed
        model_id: Identifier of the model to use
        prompt: Optional prompt for instruction-based models
    """

    texts: List[str]
    model_id: str
    prompt: Optional[str] = None


class EmbedResponse(BaseModel):
    """
    Response model for single text embedding.

    Attributes:
        embedding: The generated embedding vector
        dimension: Dimensionality of the embedding
        model_id: Identifier of the model used
        processing_time: Time taken to process the request
    """

    embedding: List[float]
    dimension: int
    model_id: str
    processing_time: float


class BatchEmbedResponse(BaseModel):
    """
    Response model for batch text embedding.

    Attributes:
        embeddings: List of generated embedding vectors
        dimension: Dimensionality of the embeddings
        model_id: Identifier of the model used
        processing_time: Time taken to process the request
    """

    embeddings: List[List[float]]
    dimension: int
    model_id: str
    processing_time: float


class SparseEmbedding(BaseModel):
    """
    Sparse embedding model.

    Attributes:
        text: The input text that was embedded
        indices: Indices of non-zero elements in the sparse vector
        values: Values corresponding to the indices
    """

    text: Optional[str] = None
    indices: List[int]
    values: List[float]


class SparseEmbedResponse(BaseModel):
    """
    Sparse embedding response model.

    Attributes:
        sparse_embedding: The generated sparse embedding
        model_id: Identifier of the model used
        processing_time: Time taken to process the request
    """

    sparse_embedding: SparseEmbedding
    model_id: str
    processing_time: float


class BatchSparseEmbedResponse(BaseModel):
    """
    Batch sparse embedding response model.

    Attributes:
        embeddings: List of generated sparse embeddings
        model_id: Identifier of the model used
    """

    embeddings: List[SparseEmbedding]
    model_id: str
    processing_time: float