| 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 | { |
nothing calls this directly
no test coverage detected