feat(clients): meta: Meta Model API module, Muse Code protocol client, demo and tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include "meta/models.h"
|
||||
|
||||
#include "meta/calls.h"
|
||||
#include "meta/check.h"
|
||||
|
||||
namespace molo::meta {
|
||||
|
||||
ModelEntry ModelEntry::from_json(const Json& j) {
|
||||
ModelEntry m;
|
||||
m.id = JsonX::str(j, "id");
|
||||
m.created = JsonX::num(j, "created");
|
||||
m.owned_by = JsonX::str(j, "owned_by");
|
||||
if (const Json* md = JsonX::obj(j, "metadata")) m.metadata = *md;
|
||||
return m;
|
||||
}
|
||||
|
||||
ServiceStatus ServiceStatus::from_json(const Json& j) {
|
||||
ServiceStatus s;
|
||||
s.is_alive = JsonX::flag(j, "is_alive");
|
||||
s.service_status = JsonX::str(j, "service_status");
|
||||
s.service_message = JsonX::str(j, "service_message");
|
||||
s.updated_at = JsonX::str(j, "updated_at");
|
||||
if (const Json* m = JsonX::arr(j, "model_statuses")) s.model_statuses = *m;
|
||||
return s;
|
||||
}
|
||||
|
||||
std::vector<ModelEntry> ModelsService::list() {
|
||||
Json doc = client_->get(path_for(Call::kModelsList));
|
||||
std::vector<ModelEntry> out;
|
||||
if (const Json* d = JsonX::arr(doc, "data"))
|
||||
for (const Json& m : d->as_array()) out.push_back(ModelEntry::from_json(m));
|
||||
return out;
|
||||
}
|
||||
|
||||
ModelEntry ModelsService::retrieve(const std::string& model_id) {
|
||||
Check::model_id(model_id);
|
||||
return ModelEntry::from_json(client_->get(path_for(Call::kModelsRetrieve, model_id)));
|
||||
}
|
||||
|
||||
ServiceStatus StatusService::get() {
|
||||
return ServiceStatus::from_json(client_->get(path_for(Call::kStatus)));
|
||||
}
|
||||
|
||||
} // namespace molo::meta
|
||||
Reference in New Issue
Block a user