MCPcopy Index your code
hub / github.com/KnowledgeXLab/LeanRAG / embedding

Function embedding

query_graph.py:31–42  ·  view source on GitHub ↗
(texts: list[str])

Source from the content-addressed store, hash-verified

29TOTAL_API_CALL_COST = 0
30
31def embedding(texts: list[str]) -> np.ndarray:
32 model_name = EMBEDDING_MODEL
33 client = OpenAI(
34 api_key=EMBEDDING_MODEL,
35 base_url=EMBEDDING_URL
36 )
37 embedding = client.embeddings.create(
38 input=texts,
39 model=model_name,
40 )
41 final_embedding = [d.embedding for d in embedding.data]
42 return np.array(final_embedding)
43
44tokenizer = tiktoken.get_encoding("cl100k_base")
45def truncate_text(text, max_tokens=4096):

Callers 1

query_graphFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected