* @brief Converts AI-tool definitions into the OpenAI tool-choice schema. */
| 328 | * @brief Converts AI-tool definitions into the OpenAI tool-choice schema. |
| 329 | */ |
| 330 | QJsonArray AI::OpenAIProvider::translateTools(const QJsonArray& tools) |
| 331 | { |
| 332 | QJsonArray out; |
| 333 | for (const auto& v : tools) { |
| 334 | const auto t = v.toObject(); |
| 335 | QJsonObject fn; |
| 336 | fn[QStringLiteral("name")] = sanitizeName(t.value(QStringLiteral("name")).toString()); |
| 337 | fn[QStringLiteral("description")] = t.value(QStringLiteral("description")); |
| 338 | fn[QStringLiteral("parameters")] = t.value(QStringLiteral("input_schema")); |
| 339 | |
| 340 | QJsonObject tool; |
| 341 | tool[QStringLiteral("type")] = QStringLiteral("function"); |
| 342 | tool[QStringLiteral("function")] = fn; |
| 343 | out.append(tool); |
| 344 | } |
| 345 | return out; |
| 346 | } |
| 347 | |
| 348 | //-------------------------------------------------------------------------------------------------- |
| 349 | // sendMessage |
nothing calls this directly
no test coverage detected