Documentation
¶
Overview ¶
Package bob is the agent for IBM Bob: the Bob IDE and Bob Shell. Its init() registers it in the agent package's default registry, so a host needs only a blank import:
import _ "github.com/rossoctl/context-guru/agent/bob"
This is a library package. It never imports a host. imports_test.go enforces that.
Index ¶
- Constants
- func BackendCounts() map[string]int64
- func IsModelInfo(method, path string) bool
- func IsProfile(method, path string) bool
- func ModelWindows(body []byte) map[string]int
- func ResetBackendForTest()
- func StripProfileRegion(b []byte) ([]byte, bool)
- type Bob
- func (Bob) Gateway() agent.GatewaySpec
- func (Bob) ModelTarget() agent.ModelTarget
- func (Bob) Name() string
- func (Bob) Paths() []string
- func (Bob) ReadUsage(contentType string, reply []byte, base agent.Usage) agent.Usage
- func (Bob) Reply(c agent.ControlCall, body []byte) agent.ControlReply
- func (Bob) SessionID(h http.Header) string
- func (Bob) WantsReply(c agent.ControlCall) bool
Constants ¶
const MaxModelWindows = 512
MaxModelWindows is the most models ModelWindows returns.
const ModelPath = "/inference/v1/chat/completions"
ModelPath is Bob's model route: the only route in Paths. Bob's control-plane paths (ProfilePath and the model-info paths) are not model routes; see controlplane.go.
const ProfilePath = "/admin/v1/profile"
ProfilePath is the profile route Bob's CLI calls before anything else, and the one response a host does not forward verbatim. See StripProfileRegion.
Variables ¶
This section is empty.
Functions ¶
func BackendCounts ¶ added in v0.7.4
BackendCounts is /stats' bob_backend: how many replies on Bob's model route got each label.
func IsModelInfo ¶ added in v0.7.4
IsModelInfo reports whether a request is the model/info GET.
func ModelWindows ¶ added in v0.7.4
ModelWindows reads data[].model_name -> data[].model_info.max_input_tokens (the LiteLLM shape Bob reads in getLiteLLMModels). A body that is not that shape gives an empty map. Metadata only: a number for each model id, at most MaxModelWindows entries.
func ResetBackendForTest ¶ added in v0.7.4
func ResetBackendForTest()
ResetBackendForTest forgets the shapes logged so far. For TESTS only.
func StripProfileRegion ¶ added in v0.7.4
StripProfileRegion removes region/region_domain from every instance in a Bob profile document, reporting false when the body is not one (then it must be forwarded as-is).
Types ¶
type Bob ¶
Bob overrides only where it differs from the neutral agent.
func (Bob) Gateway ¶ added in v0.7.4
func (Bob) Gateway() agent.GatewaySpec
Gateway: Bob's model route is OpenAI chat, and Bob owns the host's catch-all.
func (Bob) ModelTarget ¶
func (Bob) ModelTarget() agent.ModelTarget
ModelTarget sends the host's own calls to Bob's model path: Bob serves chat on no other path. Bob takes the key as `Authorization: Apikey <key>`, the way the Bob client sends it.
func (Bob) ReadUsage ¶
ReadUsage reads the cache writes from a reply on Bob's model route: the top-level `usage` of a JSON body, or the last `usage` chunk of an OpenAI chat event stream. It also sets the backend label of the reply (Usage.Backend), with or without a usage block.
func (Bob) Reply ¶ added in v0.7.4
func (Bob) Reply(c agent.ControlCall, body []byte) agent.ControlReply
Reply changes or reads the two replies WantsReply asks for.
The profile goes out with the per-instance region fields removed. Bob's client does not keep the base URL it was configured with. Having fetched the profile, `Pc.resolveBaseUrl` (bobshell 1.0.6) replaces the HOSTNAME of that URL with `api.<region_domain>` from the profile, and keeps the scheme and the PORT. Pointed at a host on 127.0.0.1:4111, its next call goes to http://api.example.com:4111, where nothing listens: seen live as "Request failed after 6 attempts: fetch failed", with no model request reaching the host. The rewrite is skipped when the instance has no region, so dropping those two fields keeps the client on the configured endpoint. A body that is not a profile gives the zero reply: the host sends it unchanged.
The model/info reply goes out unchanged. Reply gives the window Bob compacts against for each model (#963), as ModelWindows reads it.
func (Bob) SessionID ¶
SessionID is the Bob IDE's task id. The IDE sends it only in the X-Task-Id header (agent.TaskIDHeader), not in the body. Bob Shell sends metadata.taskId in the body, which the host reads before this.
func (Bob) WantsReply ¶ added in v0.7.4
func (Bob) WantsReply(c agent.ControlCall) bool
WantsReply is true for the profile GET, and for the model/info GET when not hosted. The model-info half is local-only: Bob is not deployed on hosted for now, so the rule was not designed for hosted Bob. See docs/reference/hosted-vs-local.md.