Split into category packages; module github.com/ZacharyZhang-NY/MujicaUI
This commit is contained in:
1822 files changed
+24568
-21314
No files matched your search
@@ -6,7 +6,11 @@ import (
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
mujica "mujicaui"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/chart"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/data"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/feedback"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/input"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/navigation"
|
||||
)
|
||||
|
||||
func motionInterruptDemo(c *ui.Context, log func(string)) {
|
||||
@@ -24,16 +28,16 @@ func motionInterruptDemo(c *ui.Context, log func(string)) {
|
||||
}
|
||||
navigationDemo(c, func() {
|
||||
navigationCheck(c, &s.confirm, "Confirm", log)
|
||||
if mujica.Button(c, "Start run", mujica.ButtonOptions{Variant: mujica.Secondary, Disabled: s.running}).Clicked() {
|
||||
if input.Button(c, "Start run", input.ButtonOptions{Variant: input.Secondary, Disabled: s.running}).Clicked() {
|
||||
s.running = true
|
||||
log("Run started")
|
||||
}
|
||||
}, func() {
|
||||
ui.Row(c).Gap(12).AlignItems(ui.Center).Children(func() {
|
||||
if s.running && !s.stopping {
|
||||
mujica.DotsLoader(c, mujica.LoaderOptions{Label: "Agent running", ShowLabel: true})
|
||||
feedback.DotsLoader(c, feedback.LoaderOptions{Label: "Agent running", ShowLabel: true})
|
||||
}
|
||||
if mujica.InterruptButton(c, s.running, mujica.InterruptButtonOptions{Confirm: s.confirm, Interrupting: s.stopping}).Changed() {
|
||||
if feedback.InterruptButton(c, s.running, feedback.InterruptButtonOptions{Confirm: s.confirm, Interrupting: s.stopping}).Changed() {
|
||||
log("Interrupt requested")
|
||||
s.stopping, s.until = true, c.Now().Add(1500*time.Millisecond)
|
||||
}
|
||||
@@ -44,8 +48,8 @@ func motionInterruptDemo(c *ui.Context, log func(string)) {
|
||||
func motionTokenUsageDemo(c *ui.Context, log func(string)) {
|
||||
type state struct{ line, loading, empty, failed bool }
|
||||
s := ui.Local(c.Root(), "282", func() state { return state{} })
|
||||
usage := *ui.Local(c.Root(), "282.data", func() []mujica.TokenUsage {
|
||||
return []mujica.TokenUsage{{Label: "Plan", Input: 1200, Output: 300}, {Label: "Search", Input: 4800, Output: 650},
|
||||
usage := *ui.Local(c.Root(), "282.data", func() []feedback.TokenUsage {
|
||||
return []feedback.TokenUsage{{Label: "Plan", Input: 1200, Output: 300}, {Label: "Search", Input: 4800, Output: 650},
|
||||
{Label: "Read", Input: 6100, Output: 420}, {Label: "Write", Input: 2100, Output: 2900}, {Label: "Review", Input: 3300, Output: 800}}
|
||||
})
|
||||
navigationDemo(c, func() {
|
||||
@@ -54,17 +58,17 @@ func motionTokenUsageDemo(c *ui.Context, log func(string)) {
|
||||
navigationCheck(c, &s.empty, "Empty", log)
|
||||
navigationCheck(c, &s.failed, "Error", log)
|
||||
}, func() {
|
||||
st := mujica.DataReady
|
||||
st := data.DataReady
|
||||
if s.loading {
|
||||
st = mujica.DataLoading
|
||||
st = data.DataLoading
|
||||
}
|
||||
if s.failed {
|
||||
st = mujica.DataFailed
|
||||
st = data.DataFailed
|
||||
}
|
||||
if s.empty {
|
||||
usage = nil
|
||||
}
|
||||
r := mujica.TokenUsageChart(c, usage, mujica.TokenUsageChartOptions{Line: s.line, Frame: mujica.ChartFrame{Status: st, Error: "Usage unavailable"}})
|
||||
r := feedback.TokenUsageChart(c, usage, feedback.TokenUsageChartOptions{Line: s.line, Frame: chart.ChartFrame{Status: st, Error: "Usage unavailable"}})
|
||||
if r.Changed() && r.Point >= 0 {
|
||||
log(fmt.Sprintf("Readout: mark %d", r.Point))
|
||||
}
|
||||
@@ -76,12 +80,12 @@ func motionTokenUsageDemo(c *ui.Context, log func(string)) {
|
||||
|
||||
func motionCostDemo(c *ui.Context, log func(string)) {
|
||||
type state struct {
|
||||
table mujica.CostBreakdownState
|
||||
table feedback.CostBreakdownState
|
||||
by int
|
||||
}
|
||||
s := ui.Local(c.Root(), "283", func() state { return state{} })
|
||||
items := *ui.Local(c.Root(), "283.data", func() []mujica.CostItem {
|
||||
return []mujica.CostItem{
|
||||
items := *ui.Local(c.Root(), "283.data", func() []feedback.CostItem {
|
||||
return []feedback.CostItem{
|
||||
{Model: "opus", Tool: "search", Step: "plan", InputTokens: 1000, OutputTokens: 200, Cost: 0.30},
|
||||
{Model: "haiku", Tool: "search", Step: "gather", InputTokens: 4000, OutputTokens: 500, Cost: 0.05},
|
||||
{Model: "opus", Tool: "write", Step: "write", InputTokens: 2000, OutputTokens: 3000, Cost: 1.15},
|
||||
@@ -89,11 +93,11 @@ func motionCostDemo(c *ui.Context, log func(string)) {
|
||||
}
|
||||
})
|
||||
navigationDemo(c, func() {
|
||||
if mujica.SegmentedControl(c, &s.by, []mujica.Segment{{Label: "Model"}, {Label: "Tool"}, {Label: "Step"}}, mujica.SegmentedControlOptions{Label: "Group by"}).Changed() {
|
||||
if navigation.SegmentedControl(c, &s.by, []navigation.Segment{{Label: "Model"}, {Label: "Tool"}, {Label: "Step"}}, navigation.SegmentedControlOptions{Label: "Group by"}).Changed() {
|
||||
log(fmt.Sprintf("Group by %d", s.by))
|
||||
}
|
||||
}, func() {
|
||||
v := mujica.CostBreakdown(c, &s.table, items, mujica.CostBreakdownOptions{GroupBy: mujica.CostGroup(s.by)})
|
||||
v := feedback.CostBreakdown(c, &s.table, items, feedback.CostBreakdownOptions{GroupBy: feedback.CostGroup(s.by)})
|
||||
v.Element.Height(320)
|
||||
if v.SortChanged() {
|
||||
log("Sorted by " + s.table.Table.Sort.Column)
|
||||
@@ -106,15 +110,15 @@ func motionCostDemo(c *ui.Context, log func(string)) {
|
||||
|
||||
func motionTraceDemo(c *ui.Context, log func(string)) {
|
||||
type state struct {
|
||||
viewer mujica.TraceViewerState
|
||||
viewer feedback.TraceViewerState
|
||||
empty, loading, failed, disabled bool
|
||||
}
|
||||
s := ui.Local(c.Root(), "284", func() state { return state{} })
|
||||
spans := *ui.Local(c.Root(), "284.data", func() []mujica.TraceSpan {
|
||||
return []mujica.TraceSpan{
|
||||
{ID: "run", Name: "agent.run", End: 900 * time.Millisecond, Attrs: []mujica.TraceAttr{{Key: "model", Value: "opus"}, {Key: "session", Value: "s-42"}}},
|
||||
{ID: "plan", Parent: "run", Name: "llm.plan", Start: 10 * time.Millisecond, End: 210 * time.Millisecond, Attrs: []mujica.TraceAttr{{Key: "tokens", Value: "1200"}}},
|
||||
{ID: "search", Parent: "run", Name: "tool.search", Start: 220 * time.Millisecond, End: 520 * time.Millisecond, Failed: true, Attrs: []mujica.TraceAttr{{Key: "error", Value: "timeout"}}},
|
||||
spans := *ui.Local(c.Root(), "284.data", func() []feedback.TraceSpan {
|
||||
return []feedback.TraceSpan{
|
||||
{ID: "run", Name: "agent.run", End: 900 * time.Millisecond, Attrs: []feedback.TraceAttr{{Key: "model", Value: "opus"}, {Key: "session", Value: "s-42"}}},
|
||||
{ID: "plan", Parent: "run", Name: "llm.plan", Start: 10 * time.Millisecond, End: 210 * time.Millisecond, Attrs: []feedback.TraceAttr{{Key: "tokens", Value: "1200"}}},
|
||||
{ID: "search", Parent: "run", Name: "tool.search", Start: 220 * time.Millisecond, End: 520 * time.Millisecond, Failed: true, Attrs: []feedback.TraceAttr{{Key: "error", Value: "timeout"}}},
|
||||
{ID: "fetch", Parent: "search", Name: "http.get", Start: 230 * time.Millisecond, End: 500 * time.Millisecond},
|
||||
{ID: "write", Parent: "run", Name: "llm.write", Start: 530 * time.Millisecond, End: 880 * time.Millisecond},
|
||||
}
|
||||
@@ -125,18 +129,18 @@ func motionTraceDemo(c *ui.Context, log func(string)) {
|
||||
navigationCheck(c, &s.failed, "Error", log)
|
||||
navigationCheck(c, &s.disabled, "Disabled", log)
|
||||
}, func() {
|
||||
status := mujica.DataReady
|
||||
status := data.DataReady
|
||||
if s.empty || s.loading || s.failed {
|
||||
spans = nil
|
||||
}
|
||||
if s.loading {
|
||||
status = mujica.DataLoading
|
||||
status = data.DataLoading
|
||||
}
|
||||
if s.failed {
|
||||
status = mujica.DataFailed
|
||||
status = data.DataFailed
|
||||
}
|
||||
ui.Column(c).Disabled(s.disabled).Children(func() {
|
||||
v := mujica.TraceViewer(c, &s.viewer, spans, mujica.TraceViewerOptions{Status: status, Error: "Trace unavailable"})
|
||||
v := feedback.TraceViewer(c, &s.viewer, spans, feedback.TraceViewerOptions{Status: status, Error: "Trace unavailable"})
|
||||
v.Element.Height(440)
|
||||
if id, ok := s.viewer.Tree.Selected(); ok && v.Changed() {
|
||||
log("Selected " + id)
|
||||
@@ -153,12 +157,12 @@ func motionTraceDemo(c *ui.Context, log func(string)) {
|
||||
|
||||
func motionEvalDemo(c *ui.Context, log func(string)) {
|
||||
type state struct {
|
||||
table mujica.DataTableState[string]
|
||||
table data.DataTableState[string]
|
||||
empty, loading, failed, disabled bool
|
||||
}
|
||||
s := ui.Local(c.Root(), "285", func() state { return state{} })
|
||||
cases := *ui.Local(c.Root(), "285.data", func() []mujica.EvalCase {
|
||||
return []mujica.EvalCase{
|
||||
cases := *ui.Local(c.Root(), "285.data", func() []feedback.EvalCase {
|
||||
return []feedback.EvalCase{
|
||||
{ID: "c1", Name: "Greets by title", Score: 0.98, Passed: true},
|
||||
{ID: "c2", Name: "Refuses forgery", Score: 0.41},
|
||||
{ID: "c3", Name: "Summarizes letter", Score: 0.87, Passed: true},
|
||||
@@ -171,18 +175,18 @@ func motionEvalDemo(c *ui.Context, log func(string)) {
|
||||
navigationCheck(c, &s.failed, "Error", log)
|
||||
navigationCheck(c, &s.disabled, "Disabled", log)
|
||||
}, func() {
|
||||
status := mujica.DataReady
|
||||
status := data.DataReady
|
||||
if s.empty || s.loading || s.failed {
|
||||
cases = nil
|
||||
}
|
||||
if s.loading {
|
||||
status = mujica.DataLoading
|
||||
status = data.DataLoading
|
||||
}
|
||||
if s.failed {
|
||||
status = mujica.DataFailed
|
||||
status = data.DataFailed
|
||||
}
|
||||
ui.Column(c).Disabled(s.disabled).Children(func() {
|
||||
r := mujica.EvalResultTable(c, &s.table, cases, mujica.EvalResultTableOptions{Status: status, Error: "Evaluation unavailable"})
|
||||
r := feedback.EvalResultTable(c, &s.table, cases, feedback.EvalResultTableOptions{Status: status, Error: "Evaluation unavailable"})
|
||||
r.Element.Height(320)
|
||||
if id, ok := r.Diff(); ok {
|
||||
log("Diff " + id)
|
||||
@@ -203,16 +207,16 @@ func motionEvalDemo(c *ui.Context, log func(string)) {
|
||||
|
||||
func motionToolsDemo(c *ui.Context, log func(string)) {
|
||||
type state struct {
|
||||
list mujica.ListState[string]
|
||||
tools []mujica.AgentTool
|
||||
list data.ListState[string]
|
||||
tools []feedback.AgentTool
|
||||
disabled, empty bool
|
||||
}
|
||||
s := ui.Local(c.Root(), "286", func() state {
|
||||
return state{tools: []mujica.AgentTool{
|
||||
{Name: "web_search", Description: "Search the web", Enabled: true, Params: []mujica.ToolParam{
|
||||
return state{tools: []feedback.AgentTool{
|
||||
{Name: "web_search", Description: "Search the web", Enabled: true, Params: []feedback.ToolParam{
|
||||
{Name: "query", Type: "string", Required: true, Description: "What to look for"}, {Name: "limit", Type: "integer"}}},
|
||||
{Name: "read_file", Description: "Read a local file", Params: []mujica.ToolParam{{Name: "path", Type: "string", Required: true}}},
|
||||
{Name: "run_shell", Description: "Run a shell command", Params: []mujica.ToolParam{{Name: "command", Type: "string", Required: true}, {Name: "timeout", Type: "number"}}},
|
||||
{Name: "read_file", Description: "Read a local file", Params: []feedback.ToolParam{{Name: "path", Type: "string", Required: true}}},
|
||||
{Name: "run_shell", Description: "Run a shell command", Params: []feedback.ToolParam{{Name: "command", Type: "string", Required: true}, {Name: "timeout", Type: "number"}}},
|
||||
}}
|
||||
})
|
||||
navigationDemo(c, func() {
|
||||
@@ -223,7 +227,7 @@ func motionToolsDemo(c *ui.Context, log func(string)) {
|
||||
if s.empty {
|
||||
tools = nil
|
||||
}
|
||||
r := mujica.ToolRegistryPanel(c, &s.list, tools, mujica.ToolRegistryPanelOptions{Disabled: s.disabled})
|
||||
r := feedback.ToolRegistryPanel(c, &s.list, tools, feedback.ToolRegistryPanelOptions{Disabled: s.disabled})
|
||||
r.Element.Height(320)
|
||||
if r.List.Changed() {
|
||||
name, _ := s.list.Selected()
|
||||
|
||||
Reference in new issue
Block a user