Files
ai/controllers/takes.go
zooqueenandHanzo Dev e1fd5b33ff Publish the routing bounds, the served model and the feedback body
POST /v1/ai/feedback reached the published document with no request
body, so every generated client's feedback method took no arguments and
could not name the request it rated. The takes table now names
routingRewardRequest: request_id required, signal one of the nine values
signalReward maps, rating 1 to 3.

The chat, completions, chat completions and responses operations read
X-Max-Cost and X-Max-Latency-Ms and answer X-Routed-Model, and the
document said none of it, so a client could bound a routed call or read
the model that served it only by setting raw headers. Routed names the
handlers that route; the document publishes the two bounds as optional
header parameters and the served model as a header of the 200, under the
constants sloFromHeaders reads.

Co-authored-by: Hanzo Dev <[email protected]>
2026-10-04 11:14:30 -07:00

49 lines
2.0 KiB
Go

// Copyright 2023-2026 Hanzo AI Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package controllers
import (
openai "github.com/hanzoai/go-openai"
)
// What each hand-written handler reads.
//
// answers.go is what a handler writes back; this is the body it decodes. Without
// it the model calls reached the published document with a response and no
// request, so every generated client's completion method took no body and a
// first call through an SDK had nowhere to put the model or the messages.
//
// A handler absent from the table reads no JSON body of one fixed shape.
func Takes() map[string]any { return takes }
var takes = map[string]any{
"ChatCompletions": openai.ChatCompletionRequest{},
"ChatCompletionsPublic": openai.ChatCompletionRequest{},
"AnthropicMessages": AnthropicRequest{},
// The handler reads only the model and forwards the rest verbatim; this is the
// OpenAI embedding request it forwards.
"Embeddings": openai.EmbeddingRequest{},
// Forwarded to the decision service with its handles named by the paying org;
// this is the Decisions request.
"Decisions": decisionsRequest{},
// The reward for a routed answer: its request id and the caller's signal.
"AddRoutingReward": routingRewardRequest{},
// The routing catalog editor (routing.go).
"RouterCatalogApply": routingEdit{},
"RouterCatalogPropose": routingEdit{},
"RouterCatalogRollback": routingEdit{},
"RouterCatalogTest": routingEdit{},
}