mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-01-08 22:08:03 -05:00
feat: implement CLI support for metadata display (Phase 4)
This commit is contained in:
@@ -104,6 +104,7 @@ type Flags struct {
|
|||||||
Notification bool `long:"notification" yaml:"notification" description:"Send desktop notification when command completes"`
|
Notification bool `long:"notification" yaml:"notification" description:"Send desktop notification when command completes"`
|
||||||
NotificationCommand string `long:"notification-command" yaml:"notificationCommand" description:"Custom command to run for notifications (overrides built-in notifications)"`
|
NotificationCommand string `long:"notification-command" yaml:"notificationCommand" description:"Custom command to run for notifications (overrides built-in notifications)"`
|
||||||
Thinking domain.ThinkingLevel `long:"thinking" yaml:"thinking" description:"Set reasoning/thinking level (e.g., off, low, medium, high, or numeric tokens for Anthropic or Google Gemini)"`
|
Thinking domain.ThinkingLevel `long:"thinking" yaml:"thinking" description:"Set reasoning/thinking level (e.g., off, low, medium, high, or numeric tokens for Anthropic or Google Gemini)"`
|
||||||
|
ShowMetadata bool `long:"show-metadata" description:"Print metadata to stderr"`
|
||||||
Debug int `long:"debug" description:"Set debug level (0=off, 1=basic, 2=detailed, 3=trace)" default:"0"`
|
Debug int `long:"debug" description:"Set debug level (0=off, 1=basic, 2=detailed, 3=trace)" default:"0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,6 +460,7 @@ func (o *Flags) BuildChatOptions() (ret *domain.ChatOptions, err error) {
|
|||||||
Voice: o.Voice,
|
Voice: o.Voice,
|
||||||
Notification: o.Notification || o.NotificationCommand != "",
|
Notification: o.Notification || o.NotificationCommand != "",
|
||||||
NotificationCommand: o.NotificationCommand,
|
NotificationCommand: o.NotificationCommand,
|
||||||
|
ShowMetadata: o.ShowMetadata,
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,9 +85,12 @@ func (o *Chatter) Send(request *domain.ChatRequest, opts *domain.ChatOptions) (s
|
|||||||
printedStream = true
|
printedStream = true
|
||||||
}
|
}
|
||||||
case domain.StreamTypeUsage:
|
case domain.StreamTypeUsage:
|
||||||
// Placeholder for metadata handling
|
if opts.ShowMetadata && update.Usage != nil {
|
||||||
// Future logic: Store usage in session or context
|
fmt.Fprintf(os.Stderr, "\n[Metadata] Input: %d | Output: %d | Total: %d\n",
|
||||||
|
update.Usage.InputTokens, update.Usage.OutputTokens, update.Usage.TotalTokens)
|
||||||
|
}
|
||||||
case domain.StreamTypeError:
|
case domain.StreamTypeError:
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: %s\n", update.Content)
|
||||||
errChan <- errors.New(update.Content)
|
errChan <- errors.New(update.Content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ type ChatOptions struct {
|
|||||||
Voice string
|
Voice string
|
||||||
Notification bool
|
Notification bool
|
||||||
NotificationCommand string
|
NotificationCommand string
|
||||||
|
ShowMetadata bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NormalizeMessages remove empty messages and ensure messages order user-assist-user
|
// NormalizeMessages remove empty messages and ensure messages order user-assist-user
|
||||||
|
|||||||
Reference in New Issue
Block a user