Documentation
¶
Overview ¶
Package detect contains the detect-kind AI agent: cheap, tool-free, single-call classification of unknown / spiking log patterns. It is the production AIAgent the worker consumes; the router also exposes it to admin endpoints under task kind core.AITaskDetect.
Detect MUST stay tool-free. Tool wiring is reserved for the analyze-kind agent — letting detect call tools would turn every noisy log line into a multi-step LLM workflow.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
func BuildPrompt(r core.AgentResult, source, service string, samples []string) (system, user string)
BuildPrompt builds the (system, user) messages for a single AgentResult. Pure function: no I/O, no time. Easy to golden-test.
func ParseFinding ¶
ParseFinding accepts the model's reply and returns an AIFinding. Tolerates the most common deviations: leading/trailing prose, ```json fences, prepended "Here is the JSON:" preamble.
func PromptOrder ¶
func PromptOrder() []string
PromptOrder returns the canonical fragment order so the admin endpoint can echo the list back to the UI alongside the assembled prompt.
func SystemPrompt ¶
func SystemPrompt() string
SystemPrompt returns the assembled system prompt sent on every detect call. Exposed so the admin API can render it for operators.
Types ¶
type Agent ¶
type Agent struct {
// SampleFn picks the lines forwarded to the model from an
// AgentResult. Defaults to "first up to 3 non-empty messages".
// Exposed so callers can swap in a redaction-aware extractor.
SampleFn func(core.AgentResult) []string
// contains filtered or unexported fields
}
Agent is the detect-kind AIAgent. It binds the resolved per-task config, the Eino chat model, and a sample extractor.
func New ¶
New constructs a detect Agent. cfg must already be resolved for the detect task (see config.AgentAIConfig.Resolve).
func (*Agent) ChatModel ¶
func (a *Agent) ChatModel() model.BaseChatModel
ChatModel exposes the underlying Eino model. Only used by the tool-free guard test in agent_test.go. It returns the currently-built model from the holder (built eagerly in New); it never triggers a rebuild.
type Options ¶
type Options struct {
// HTTPClient overrides the default *http.Client. Optional.
HTTPClient *http.Client
// BaseURL overrides the chat/completions endpoint. Tests use this
// to point at an httptest server; production leaves it empty.
BaseURL string
// Timeout caps each chat call. Defaults to 30s.
Timeout time.Duration
// AuthKeyFunc is an OPTIONAL per-request Authorization override passed
// straight to the chat model's transport. Nil (the OSS default) leaves
// the YAML-keyed header untouched.
AuthKeyFunc func(ctx context.Context) (key string, ok bool)
// Runtime folds optional runtime overrides (provider / enabled / key
// state) into the model holder's rebuild signature. The zero value (the
// OSS default) pins the configured provider and builds the model once.
Runtime einowrap.RuntimeAI
}
Options is the constructor-side bag for test plumbing. Production callers pass a zero Options{} and let the agent dial OpenAI directly.