feat(clients): llm vendor foundation: api client, SSE, errors, neutral chat types, ai.mk, example stubs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 06:06:06 +02:00
co-authored by Claude Sonnet 5.5
parent 6f73535b82
commit 4c78017742
26 changed files with 1269 additions and 5 deletions
+31
View File
@@ -0,0 +1,31 @@
#pragma once
// LLM vendor platform demos (xAI, Anthropic, Meta, DeepSeek). One register
// function per work package, each in its own file under example/app/ai/.
// Every route lives under /ai/<vendor> and is excluded from locust (paid
// APIs). Rules for a demo:
// - GET pages and status routes answer 2xx without credentials (the matrix
// test crawls them); a route that would call the vendor is POST or DELETE
// and answers 503 not_configured without a credential, 422 on bad input,
// and costly or destructive ones are dry runs unless the body has
// "confirm":true.
// - State lives in objects created inside the register function and
// captured by the handlers; do not edit Services.
// - Clients come from llm::ApiClient::from_env(...) (null key is fine: the
// vendor service then reports not configured).
#include "App.hpp"
namespace molo::example::app {
void register_ai_xai_demo(fw::Router& router, Services& services);
void register_ai_xaiplatform_demo(fw::Router& router, Services& services);
void register_ai_anthropic_demo(fw::Router& router, Services& services);
void register_ai_anthropicadmin_demo(fw::Router& router, Services& services);
void register_ai_meta_demo(fw::Router& router, Services& services);
void register_ai_deepseek_demo(fw::Router& router, Services& services);
// Mounts every vendor router at "" (called once from build_application).
void register_ai_demos(std::shared_ptr<fw::Application> app, Services& services);
} // namespace molo::example::app
+2
View File
@@ -1,5 +1,6 @@
#include "App.hpp"
#include "AgentDemos.hpp"
#include "AiDemos.hpp"
namespace molo::example::app {
@@ -73,6 +74,7 @@ std::shared_ptr<fw::Application> build_application(Services& services) {
app->include_router("", voice);
register_agent_demos(app, services);
register_ai_demos(app, services);
register_chain_demo(app, services);
return app;
+40
View File
@@ -0,0 +1,40 @@
#include "../AiDemos.hpp"
#include "../../fw/Router.hpp"
namespace molo::example::app {
void register_ai_demos(std::shared_ptr<fw::Application> app, Services& services) {
{
fw::Router r;
register_ai_xai_demo(r, services);
app->include_router("", r);
}
{
fw::Router r;
register_ai_xaiplatform_demo(r, services);
app->include_router("", r);
}
{
fw::Router r;
register_ai_anthropic_demo(r, services);
app->include_router("", r);
}
{
fw::Router r;
register_ai_anthropicadmin_demo(r, services);
app->include_router("", r);
}
{
fw::Router r;
register_ai_meta_demo(r, services);
app->include_router("", r);
}
{
fw::Router r;
register_ai_deepseek_demo(r, services);
app->include_router("", r);
}
}
} // namespace molo::example::app
+13
View File
@@ -0,0 +1,13 @@
#include "../AiDemos.hpp"
#include "../../fw/Router.hpp"
namespace molo::example::app {
// Anthropic Claude: admin API (orgs, workspaces, keys, usage, cost) and managed agents. Stub: the module agent fills this in.
void register_ai_anthropicadmin_demo(fw::Router& router, Services& services) {
(void)router;
(void)services;
}
} // namespace molo::example::app
+13
View File
@@ -0,0 +1,13 @@
#include "../AiDemos.hpp"
#include "../../fw/Router.hpp"
namespace molo::example::app {
// Anthropic Claude: messages, streaming, tools, batches, tokens, models, files, skills. Stub: the module agent fills this in.
void register_ai_anthropic_demo(fw::Router& router, Services& services) {
(void)router;
(void)services;
}
} // namespace molo::example::app
+13
View File
@@ -0,0 +1,13 @@
#include "../AiDemos.hpp"
#include "../../fw/Router.hpp"
namespace molo::example::app {
// DeepSeek API. Stub: the module agent fills this in.
void register_ai_deepseek_demo(fw::Router& router, Services& services) {
(void)router;
(void)services;
}
} // namespace molo::example::app
+13
View File
@@ -0,0 +1,13 @@
#include "../AiDemos.hpp"
#include "../../fw/Router.hpp"
namespace molo::example::app {
// Meta Llama API. Stub: the module agent fills this in.
void register_ai_meta_demo(fw::Router& router, Services& services) {
(void)router;
(void)services;
}
} // namespace molo::example::app
+13
View File
@@ -0,0 +1,13 @@
#include "../AiDemos.hpp"
#include "../../fw/Router.hpp"
namespace molo::example::app {
// xAI Grok: chat, responses, tools, media, batch, models. Stub: the module agent fills this in.
void register_ai_xai_demo(fw::Router& router, Services& services) {
(void)router;
(void)services;
}
} // namespace molo::example::app
+13
View File
@@ -0,0 +1,13 @@
#include "../AiDemos.hpp"
#include "../../fw/Router.hpp"
namespace molo::example::app {
// xAI Grok: voice/realtime, collections, files, management API. Stub: the module agent fills this in.
void register_ai_xaiplatform_demo(fw::Router& router, Services& services) {
(void)router;
(void)services;
}
} // namespace molo::example::app
+2 -2
View File
@@ -17,8 +17,8 @@ LOCUST = HERE / "locustfile.py"
EXCLUDED = {"/voice/say", "/voice/hear", "/voice/turn", "/voice/reset"}
# Whole areas that talk to (or front) paid Google APIs. Routes under these
# prefixes are never load tested and never required to be covered.
EXCLUDED_PREFIXES = ("/voice", "/google", "/agent", "/embedded/voice.js",
"/embedded/agent_")
EXCLUDED_PREFIXES = ("/voice", "/google", "/agent", "/ai", "/embedded/voice.js",
"/embedded/agent_", "/embedded/ai_")
def is_excluded(route: str) -> bool:
+4 -2
View File
@@ -54,7 +54,8 @@ EXAMPLE_SRCS = \
$(EXAMPLE_DIR)/app/EnterpriseDemo.cpp \
$(EXAMPLE_DIR)/app/ResilienceDemo.cpp \
$(EXAMPLE_DIR)/app/VoiceDemo.cpp \
$(sort $(wildcard $(EXAMPLE_DIR)/app/agent/*.cpp))
$(sort $(wildcard $(EXAMPLE_DIR)/app/agent/*.cpp)) \
$(sort $(wildcard $(EXAMPLE_DIR)/app/ai/*.cpp))
# Tests are discovered: every tests/example/**/*_test.cpp is one route test.
EXAMPLE_TEST_JOBS ?= 8
@@ -71,7 +72,7 @@ EXAMPLE_ASSETS = $(sort $(wildcard $(EXAMPLE_DIR)/assets/*))
EXAMPLE_INC = -I$(EXAMPLE_DIR) -I$(EXAMPLE_BUILD) -Isrc
# Real framework parts the example links: Google Cloud (src/google) over the
# HTTP client (src/clients, wolfSSL TLS) and the operability breaker.
EXAMPLE_REAL_LIBS = build/google/libgoogle.a build/clients/libclients.a \
EXAMPLE_REAL_LIBS = build/ai/libai.a build/google/libgoogle.a build/clients/libclients.a \
build/liboperability.a
.PHONY: example-deploy example-verify deploy verify example example-real-libs example-assets example-test example-clean example-locust
@@ -93,6 +94,7 @@ example-real-libs:
$(MAKE) -f src/operability.mk build/liboperability.a
$(MAKE) -f src/clients/clients.mk clients
$(MAKE) -f src/google/google.mk google
$(MAKE) -f src/ai.mk ai
example: example-assets example-real-libs
mkdir -p $(EXAMPLE_BUILD)/obj
+1 -1
View File
@@ -87,7 +87,7 @@ GETS = [
"/webdav/files/test.txt",
]
# NOT load tested on purpose: everything under /voice, /google and /agent
# NOT load tested on purpose: everything under /voice, /google, /agent and /ai
# calls or fronts paid Google APIs (check_locust_coverage.py enforces this).
POSTS = [
("/audit/log", {"event": "locust"}),