MCPcopy Create free account
hub / github.com/TencentCloudADP/youtu-embedding / encode

Function encode

usage/tencent_cloud_api.py:15–33  ·  view source on GitHub ↗
(client, inputs, is_query=False)

Source from the content-addressed store, hash-verified

13
14
15def encode(client, inputs, is_query=False):
16 if is_query:
17 instruction = "Instruction: Given a search query, retrieve passages that answer the question \nQuery:"
18 else:
19 instruction = ""
20
21 params = {
22 "Model": model_name,
23 "Inputs": inputs,
24 "Instruction": instruction
25 }
26
27 req = models.GetEmbeddingRequest()
28 req.from_json_string(json.dumps(params))
29
30 resp = client.GetEmbedding(req)
31 resp = json.loads(resp.to_json_string())
32 outputs =[item["Embedding"] for item in resp["Data"]]
33 return outputs
34
35secret_id = os.getenv("TENCENTCLOUD_SECRET_ID")
36secret_key = os.getenv("TENCENTCLOUD_SECRET_KEY")

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected