MCPcopy Create free account
hub / github.com/TaskingAI/TaskingAI / embed_query

Function embed_query

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

embed the query text :param query: the query text :param embedding_model: the embedding_model to use :param embedding_size: the embedding size of the model :return: the embedding vector

(query: str, embedding_model: Model, embedding_size: int)

Source from the content-addressed store, hash-verified

28
29
30async def embed_query(query: str, embedding_model: Model, embedding_size: int):
31 """
32 embed the query text
33 :param query: the query text
34 :param embedding_model: the embedding_model to use
35 :param embedding_size: the embedding size of the model
36 :return: the embedding vector
37 """
38
39 if CONFIG.DEV:
40 return _generate_random_unit_vector(query, embedding_size)
41
42 response = await text_embedding(
43 model=embedding_model,
44 encrypted_credentials=embedding_model.encrypted_credentials,
45 input_text_list=[query],
46 input_type="query",
47 )
48 check_http_error(response)
49 return response.json()["data"][0]["embedding"]
50
51
52async def embed_documents(documents: List[str], embedding_model: Model, embedding_size: int) -> List[List[float]]:

Callers 1

query_chunksFunction · 0.85

Calls 4

text_embeddingFunction · 0.90
check_http_errorFunction · 0.90
jsonMethod · 0.45

Tested by

no test coverage detected