MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / send_embedding

Method send_embedding

examples/server/server.cpp:1219–1248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1217 }
1218
1219 void send_embedding(llama_client_slot &slot)
1220 {
1221 std::lock_guard<std::mutex> lock(mutex_results);
1222 task_result res;
1223 res.id = slot.task_id;
1224 res.error = false;
1225 res.stop = true;
1226
1227 const int n_embd = llama_n_embd(model);
1228 if (!params.embedding)
1229 {
1230 LOG_WARNING("embedding disabled", {
1231 {"params.embedding", params.embedding},
1232 });
1233 res.result_json = json
1234 {
1235 {"embedding", std::vector<float>(n_embd, 0.0f)},
1236 };
1237 }
1238 else
1239 {
1240 const float *data = llama_get_embeddings(ctx);
1241 std::vector<float> embedding(data, data + n_embd);
1242 res.result_json = json
1243 {
1244 {"embedding", embedding },
1245 };
1246 }
1247 queue_results.push_back(res);
1248 }
1249
1250 int request_completion(json data, bool infill, bool embedding)
1251 {

Callers

nothing calls this directly

Calls 3

llama_n_embdFunction · 0.50
llama_get_embeddingsFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected