Files
LocalAI [bot] fa3b541f25 chore(ci): fix gofmt + gosimple lint failures on main (#48)
CI's fmt gate (`go fmt ./...` must be a no-op) and the golangci-lint
job (gosimple default linter) were red on main, independent of any
feature work:

- gofmt: clients/localai_client.go, prompt/prompt.go, stream.go were
  not gofmt-clean.
- gosimple S1011 (autoimprove.go): a loop appending each message is
  replaced with a single variadic append.

No behaviour change. Verified: `go fmt ./...` no-op, `go vet ./...`
clean, `go build ./...` ok, and golangci-lint v1.64.8 (the version CI
pins) exits 0.

Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 16:19:50 +02:00

34 lines
1.5 KiB
Go

package cogito
// StreamEventType identifies the kind of streaming event.
type StreamEventType string
const (
StreamEventReasoning StreamEventType = "reasoning" // LLM thinking delta
StreamEventContent StreamEventType = "content" // answer text delta
StreamEventToolCall StreamEventType = "tool_call" // tool selected + args
StreamEventToolResult StreamEventType = "tool_result" // tool execution result
StreamEventStatus StreamEventType = "status" // status message
StreamEventDone StreamEventType = "done" // stream complete
StreamEventError StreamEventType = "error" // error
StreamEventSubAgent StreamEventType = "sub_agent" // sub-agent event
)
// StreamEvent represents a single streaming event from the LLM or tool pipeline.
type StreamEvent struct {
Type StreamEventType
Content string // text delta (reasoning/content)
ToolName string // for tool_call/tool_result — name (first chunk only)
ToolArgs string // for tool_call: argument delta string
ToolCallID string // OpenAI tool_call ID (first chunk only)
ToolCallIndex int // which tool call (for parallel tool calls)
ToolResult string // tool result text
FinishReason string // "stop", "tool_calls", etc. (populated on done)
Error error // populated on error
Usage LLMUsage // populated on done
AgentID string // populated for sub-agent events
}
// StreamCallback is a function that receives streaming events.
type StreamCallback func(StreamEvent)