MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / embed_documents

Function embed_documents

backend/app/services/retrieval/embedding.py:52–71  ·  view source on GitHub ↗

embed the query text :param documents: the text list of the documents :param embedding_model: the embedding_model to use :param embedding_size: the embedding size of the model :return: a list of embedding vectors

(documents: List[str], embedding_model: Model, embedding_size: int)

Source from the content-addressed store, hash-verified

50
51
52async def embed_documents(documents: List[str], embedding_model: Model, embedding_size: int) -> List[List[float]]:
53 """
54 embed the query text
55 :param documents: the text list of the documents
56 :param embedding_model: the embedding_model to use
57 :param embedding_size: the embedding size of the model
58 :return: a list of embedding vectors
59 """
60
61 if CONFIG.DEV:
62 return [_generate_random_unit_vector(text, embedding_size) for text in documents]
63
64 response = await text_embedding(
65 model=embedding_model,
66 encrypted_credentials=embedding_model.encrypted_credentials,
67 input_text_list=documents,
68 input_type="document",
69 )
70 check_http_error(response)
71 return [d["embedding"] for d in response.json()["data"]]

Callers 3

process_contentFunction · 0.90
createMethod · 0.90
updateMethod · 0.90

Calls 4

text_embeddingFunction · 0.90
check_http_errorFunction · 0.90
jsonMethod · 0.45

Tested by

no test coverage detected