Route AiClient through local AI Broker instead of direct provider calls #15
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
#63 Consolidate
herolib_ai into hero_aibroker_sdk (single AI client)
lhumina_code/hero_aibroker
Reference
lhumina_code/hero_biz#15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The current
AiClientincrates/hero_biz_ui/src/ai/client.rsis an OpenAI-compatible HTTP client that calls external AI providers directly viabase_url+api_keyonAiProvider. This breaks the intended Hero stack architecture.Required Architecture
All AI calls must flow through the local AI Broker:
The broker already exists (
hero_aibroker) and exposes an OpenAI-compatible REST surface at~/hero/var/sockets/hero_aibroker/rest.sock.SDK Gap — Blocker
hero_biz uses non-streaming chat exclusively (
analyze_intent,generate_suggestions, all assistant calls go throughAiClient.chat()). The currenthero_aibroker_sdkonly provides:AIBrokerAdminAPIClient— admin RPC only (health, models, info), no chatStreamingClient— forcesstream: true, streaming onlyAIBrokerRawClient— raw JSON-RPC; chat is not exposed over the RPC socketThere is no non-streaming chat client in the SDK. This must be resolved first.
Path Forward
Step 1 (prerequisite — work in
hero_aibroker): Add a non-streaming REST client tohero_aibroker_sdkthat POSTs torest.sockat/v1/chat/completionswithout forcing streaming. Something like aRestClientalongside the existingStreamingClient.Step 2 (this repo): Replace hero_biz's
AiClientwith the new SDK client:AiProvider,AiConfig, and all provider/API key config from hero_biz — that becomes the broker's concerntry_chatfallback loop — failover is handled inside the brokerchat(),transcribe(), andtts()calls to the broker REST socket via the SDKReferences
crates/hero_biz_ui/src/ai/client.rs—AiClient,try_chat,try_transcribe,try_ttscrates/hero_biz_ui/src/ai/config.rs—AiProvider,AiConfig,AiModelhero_aibroker/crates/hero_aibroker_sdk/src/streaming.rs— existingStreamingClient(streaming only)hero_aibroker/crates/hero_aibroker_sdk/src/lib.rs—AIBrokerAdminAPIClient,AIBrokerRawClientherolib_aiintohero_aibroker_sdk(single AI client)Blocked by lhumina_code/hero_aibroker#63
This issue cannot start until
hero_aibroker_sdkexposes a non-streaming REST chat client. The SDK currently only hasStreamingClientandAIBrokerAdminAPIClient— neither supports a plainPOST /v1/chat/completionswithout forcing streaming.The prerequisite work is tracked in hero_aibroker#63 — Consolidate herolib_ai into hero_aibroker_sdk. Specifically, step 1 of that issue (add
from_default_socket()+ non-streaming chat toHeroAibrokerClient) must land before this can proceed.herolib_aiintohero_aibroker_sdk(single AI client) #63