feat(clients): azure: Azure OpenAI and AI Foundry package, 147-row spec table, Entra auth, demo

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 15:04:27 +01:00
co-authored by Claude Sonnet 5.5
parent 3db67fcf1f
commit a2c1186036
67 changed files with 6607 additions and 3 deletions
+49
View File
@@ -0,0 +1,49 @@
#include "vendors/azure/audio.h"
#include "vendors/azure/caps.h"
#include "vendors/azure/check.h"
namespace molo::azure {
using clients::body::Json;
llm::RawResponse AudioService::speech(const std::string& deployment, const Json& body) {
Check::deployment(deployment);
Check::object("body", body);
Check::has_string(body, "input");
Check::has_string(body, "voice");
Check::max_chars("input", body.find("input")->as_string(), AzureCaps::kMaxSpeechChars);
return call_json_raw(Op::kCreateSpeech, {deployment, {}}, body);
}
llm::RawResponse AudioService::upload(Op op, const std::string& deployment, const UploadFile& file,
const std::map<std::string, std::string>& fields) {
Check::deployment(deployment);
Check::non_empty("audio filename", file.filename);
Check::no_control("filename", file.filename);
Check::require(!file.data.empty(), "audio file is empty");
Check::require(file.data.size() <= AzureCaps::kMaxAudioFileBytes, "audio file over 25 MiB");
clients::body::MultipartBody form;
form.add_file("file", file.filename, file.content_type, file.data);
for (const auto& [k, v] : fields) form.add_text(k, v);
return call_multipart_raw(op, {deployment, {}}, form);
}
llm::RawResponse AudioService::transcribe(const std::string& deployment, const UploadFile& file,
const std::map<std::string, std::string>& fields) {
return upload(Op::kCreateTranscription, deployment, file, fields);
}
llm::RawResponse AudioService::translate(const std::string& deployment, const UploadFile& file,
const std::map<std::string, std::string>& fields) {
return upload(Op::kCreateTranslation, deployment, file, fields);
}
Json AudioService::as_json(const llm::RawResponse& answer) {
if (answer.content_type.find("json") != std::string::npos) return Json::parse(answer.body);
Json o = Json::object();
o.set("text", Json(answer.body));
return o;
}
} // namespace molo::azure