mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-01-09 14:28:01 -05:00
feat: add domain types for structured streaming (Phase 1)
This commit is contained in:
24
internal/domain/stream.go
Normal file
24
internal/domain/stream.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package domain
|
||||
|
||||
// StreamType distinguishes between partial text content and metadata events.
|
||||
type StreamType string
|
||||
|
||||
const (
|
||||
StreamTypeContent StreamType = "content"
|
||||
StreamTypeUsage StreamType = "usage"
|
||||
StreamTypeError StreamType = "error"
|
||||
)
|
||||
|
||||
// StreamUpdate is the unified payload sent through the internal channels.
|
||||
type StreamUpdate struct {
|
||||
Type StreamType `json:"type"`
|
||||
Content string `json:"content,omitempty"` // For text deltas
|
||||
Usage *UsageMetadata `json:"usage,omitempty"` // For token counts
|
||||
}
|
||||
|
||||
// UsageMetadata normalizes token counts across different providers.
|
||||
type UsageMetadata struct {
|
||||
InputTokens int `json:"input_tokens"`
|
||||
OutputTokens int `json:"output_tokens"`
|
||||
TotalTokens int `json:"total_tokens"`
|
||||
}
|
||||
Reference in New Issue
Block a user