fix(server,sdk): unwrap params.request on chat methods; drop hand-rolled chat client #141
No reviewers
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.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_aibroker!141
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_align_chat_drop_sdk_specs"
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?
Closes #140, closes #139.
#140 — chat handler unwraps
params["request"]The chat domain spec declares each method's params as a single named field (
{"name": "request", "schema": ChatRequest}), per OpenRPC named-params convention. The chat handlers were reading params flat (params.get("model")directly), so macro-generated clients sending{"jsonrpc":"2.0","method":"ai.chat","params":{"request":{...}}}got'model' parameter required.Added
unwrap_request_param()incrates/hero_aibroker_server/src/api_openrpc/chat/handlers.rs: takesparams["request"]when it's a JSON object, else passes through unchanged. Applied toai.chat,ai.messages,ai.responses,ai.completions. Spec + handler now agree; both wrapped and flat inputs work (the latter for legacy callers).#139 — SDK consumes server specs directly; drop hand-rolled chat client
hero_aibroker_sdk::chat::Clientwas a hand-rolled wrapper aroundOpenRpcTransportthat bypassed the macro-generated client to sendChatRequestflat. With #140 fixing the underlying mismatch, the chat domain now uses the samedomain_client!()pattern as the other 9 domains. Net delete inlib.rs: ~50 LOC.Lifted as crate-level / module-level helpers (not bound to a hand-rolled struct anymore):
crate::extract_chat_content(v)— pull a content string out of anai.chatresponse envelope.chat::MessageContent::text(s)—V0(Value::String(s))builder.chat::Client::ai_chat_content(req)— convenience: send aChatRequest, get back the assistant's content as aString.PromptBuilderand the verify example switched to the macro-generated shape:client.ai_chat(AiChatInput { request: ChatRequest }).The two
allOfschemas that previously blocked the macro (TranscriptionVerbosein speech,memory.searchresult item in memory) were already inlined upstream —grep -c '"allOf"' specs/*.jsonis 0 across all 10 server specs. The SDK's old filtered copies (crates/hero_aibroker_sdk/specs/) were already removed before this PR.Verification
cargo buildclean for bothhero_aibroker_serverandhero_aibroker_sdkcargo test -p hero_aibroker_sdk --doc— 3/3 compile-okcargo clippy -p hero_aibroker_sdk --no-deps -- -D warnings— cleanlab --release --bin hero_aibroker_server --force --install+lab --stop hero_aibroker_server+lab --release --start, thencargo run -p hero_aibroker_examples --example verify_127_chatreturns real Groq output:content: "verified", full OpenAI envelope intact. Confirms the macro-generated client sends spec-shape{"request":{...}}params and the handler unwraps them correctly.🤖 Generated with Claude Code
ai.chathandler param shape with its OpenRPC spec #140View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.