Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 9218cd9

Browse files
committed
feat: Add input as vector
1 parent 1485be2 commit 9218cd9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

controllers/llamaCPP.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,22 @@ void llamaCPP::embedding(
408408

409409
json prompt;
410410
if (jsonBody->isMember("input") != 0) {
411-
prompt = (*jsonBody)["input"].asString();
411+
if ((*jsonBody)["input"].isString()) {
412+
prompt = (*jsonBody)["input"].asString();
413+
} else if ((*jsonBody)["input"].isArray()) {
414+
const auto &inputArray = (*jsonBody)["input"];
415+
std::vector<std::string> inputStrings;
416+
for (const auto &input : inputArray) {
417+
if (input.isString()) {
418+
inputStrings.push_back(input.asString());
419+
}
420+
}
421+
prompt = inputStrings;
422+
}
412423
} else {
413424
prompt = "";
414425
}
426+
415427
const int task_id = llama.request_completion(
416428
{{"prompt", prompt}, {"n_predict", 0}}, false, true, -1);
417429
task_result result = llama.next_result(task_id);

0 commit comments

Comments
 (0)