MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / from_embeddings

Method from_embeddings

examples/server/server.py:2658–2684  ·  view source on GitHub ↗
(
        cls,
        *,
        model: str,
        embeddings: Sequence[Sequence[float]],
        total_tokens: int,
        encoding_format: Literal["float", "base64"],
        dimensions: Optional[int],
    )

Source from the content-addressed store, hash-verified

2656
2657 @classmethod
2658 def from_embeddings(
2659 cls,
2660 *,
2661 model: str,
2662 embeddings: Sequence[Sequence[float]],
2663 total_tokens: int,
2664 encoding_format: Literal["float", "base64"],
2665 dimensions: Optional[int],
2666 ) -> "CreateEmbeddingResponse":
2667 return cls(
2668 data=[
2669 EmbeddingDataResponse(
2670 embedding=cls.encode_embedding(
2671 embedding,
2672 encoding_format,
2673 dimensions,
2674 ),
2675 index=index,
2676 )
2677 for index, embedding in enumerate(embeddings)
2678 ],
2679 model=model,
2680 usage=EmbeddingUsageResponse(
2681 prompt_tokens=total_tokens,
2682 total_tokens=total_tokens,
2683 ),
2684 )
2685
2686
2687class ChatCompletionFunctionCall(BaseModel):

Callers 1

create_embeddingMethod · 0.80

Calls 3

encode_embeddingMethod · 0.80

Tested by

no test coverage detected