mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-12 00:45:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f9167bc54 | ||
|
|
3979583fe3 | ||
|
|
581f656824 | ||
|
|
e78bfb9f53 |
@@ -1,6 +1,6 @@
|
|||||||
module github.com/lukaszraczylo/harness-sync
|
module github.com/lukaszraczylo/harness-sync
|
||||||
|
|
||||||
go 1.26.0
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/charmbracelet/huh v1.0.0
|
github.com/charmbracelet/huh v1.0.0
|
||||||
@@ -20,7 +20,7 @@ require (
|
|||||||
github.com/charmbracelet/bubbletea v1.3.10 // indirect
|
github.com/charmbracelet/bubbletea v1.3.10 // indirect
|
||||||
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||||
github.com/charmbracelet/x/ansi v0.11.8 // indirect
|
github.com/charmbracelet/x/ansi v0.11.7 // indirect
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
||||||
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
||||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||||
@@ -30,10 +30,10 @@ require (
|
|||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
|
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
github.com/mattn/go-isatty v0.0.23 // indirect
|
||||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.29 // indirect
|
github.com/mattn/go-runewidth v0.0.24 // indirect
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
||||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||||
@@ -41,7 +41,7 @@ require (
|
|||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/spf13/pflag v1.0.10 // indirect
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
github.com/xo/terminfo v1.0.0 // indirect
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||||
golang.org/x/sys v0.48.0 // indirect
|
golang.org/x/sys v0.47.0 // indirect
|
||||||
golang.org/x/text v0.42.0 // indirect
|
golang.org/x/text v0.40.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ github.com/charmbracelet/huh v1.0.0 h1:wOnedH8G4qzJbmhftTqrpppyqHakl/zbbNdXIWJyI
|
|||||||
github.com/charmbracelet/huh v1.0.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
github.com/charmbracelet/huh v1.0.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
||||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||||
github.com/charmbracelet/x/ansi v0.11.8 h1:JMFwp0CgDC2+jcOB162HH5k7I3FVbgFSMMYg7dSPBQQ=
|
github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=
|
||||||
github.com/charmbracelet/x/ansi v0.11.8/go.mod h1:ZNN+3mXny/516oTQPLMPIBeSINvNJJQ8uQXDgbeJxY0=
|
github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
|
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
|
||||||
github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U=
|
github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U=
|
||||||
@@ -51,16 +51,16 @@ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6
|
|||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss=
|
github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.1/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/lukaszraczylo/oss-telemetry v0.2.3 h1:xoDtBqeZGmXj7IteiE1M5WMuzeoqag58qEleI0Cf2Ms=
|
github.com/lukaszraczylo/oss-telemetry v0.2.3 h1:xoDtBqeZGmXj7IteiE1M5WMuzeoqag58qEleI0Cf2Ms=
|
||||||
github.com/lukaszraczylo/oss-telemetry v0.2.3/go.mod h1:+Cn78qZo8rc3T9eZt0v3oICYRdd75wORtSidc8lNjDQ=
|
github.com/lukaszraczylo/oss-telemetry v0.2.3/go.mod h1:+Cn78qZo8rc3T9eZt0v3oICYRdd75wORtSidc8lNjDQ=
|
||||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
github.com/mattn/go-isatty v0.0.23 h1:cYwCQTQf3HB6xUC+BtyCLZNr7IzbOmoZbmssVNzSyiQ=
|
||||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
github.com/mattn/go-isatty v0.0.23/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
||||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
||||||
github.com/mattn/go-runewidth v0.0.29 h1:3oGF3R/S2N9DQ3ptftzVIvg2eicmojCzlwBEmqEPDfQ=
|
github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=
|
||||||
github.com/mattn/go-runewidth v0.0.29/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
|
github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
||||||
@@ -85,16 +85,16 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
|||||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/xo/terminfo v1.0.0 h1:2ZpYzqWzyyytjk3TP6aJVDhkMAkc99/1xKQdA3TDTBY=
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||||
github.com/xo/terminfo v1.0.0/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ func GatewayProviderKey(gatewayURL string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// crushModel builds a 10-field model entry required by the crush schema.
|
// crushModel builds a 10-field model entry required by the crush schema.
|
||||||
func crushModel(m canonical.Model) map[string]any {
|
func crushModel(id string) map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"id": m.ID,
|
"id": id,
|
||||||
"name": m.ID,
|
"name": id,
|
||||||
"cost_per_1m_in": 0,
|
"cost_per_1m_in": 0,
|
||||||
"cost_per_1m_out": 0,
|
"cost_per_1m_out": 0,
|
||||||
"cost_per_1m_in_cached": 0,
|
"cost_per_1m_in_cached": 0,
|
||||||
"cost_per_1m_out_cached": 0,
|
"cost_per_1m_out_cached": 0,
|
||||||
"context_window": m.ContextLimit(),
|
"context_window": 200000,
|
||||||
"default_max_tokens": m.OutputLimit(),
|
"default_max_tokens": 8192,
|
||||||
"can_reason": false,
|
"can_reason": false,
|
||||||
"supports_attachments": true,
|
"supports_attachments": true,
|
||||||
}
|
}
|
||||||
@@ -56,10 +56,10 @@ func ProvidersAsCrushMap(p *canonical.Profile) map[string]any {
|
|||||||
}
|
}
|
||||||
models := make([]map[string]any, 0)
|
models := make([]map[string]any, 0)
|
||||||
for _, m := range p.Models {
|
for _, m := range p.Models {
|
||||||
models = append(models, crushModel(m))
|
models = append(models, crushModel(m.ID))
|
||||||
}
|
}
|
||||||
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
||||||
models = append(models, crushModel(canonical.Model{ID: p.Gateway.DefaultModel}))
|
models = append(models, crushModel(p.Gateway.DefaultModel))
|
||||||
}
|
}
|
||||||
out[GatewayProviderKey(p.Gateway.URL)] = map[string]any{
|
out[GatewayProviderKey(p.Gateway.URL)] = map[string]any{
|
||||||
"type": "openai-compat",
|
"type": "openai-compat",
|
||||||
@@ -101,7 +101,7 @@ func ProvidersAsMap(p *canonical.Profile) map[string]any {
|
|||||||
}
|
}
|
||||||
models[m.ID] = map[string]any{
|
models[m.ID] = map[string]any{
|
||||||
"name": displayName,
|
"name": displayName,
|
||||||
"limit": map[string]any{"context": m.ContextLimit(), "output": m.OutputLimit()},
|
"limit": map[string]any{"context": 200000, "output": 8192},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry := map[string]any{
|
entry := map[string]any{
|
||||||
@@ -172,7 +172,7 @@ func GooseCustomProviderFile(p *canonical.Profile) ([]byte, string) {
|
|||||||
for _, m := range p.Models {
|
for _, m := range p.Models {
|
||||||
models = append(models, map[string]any{
|
models = append(models, map[string]any{
|
||||||
"name": m.ID,
|
"name": m.ID,
|
||||||
"context_limit": m.ContextLimit(),
|
"context_limit": 200000,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
||||||
@@ -183,7 +183,7 @@ func GooseCustomProviderFile(p *canonical.Profile) ([]byte, string) {
|
|||||||
}
|
}
|
||||||
models = append(models, map[string]any{
|
models = append(models, map[string]any{
|
||||||
"name": modelID,
|
"name": modelID,
|
||||||
"context_limit": canonical.DefaultContextLimit,
|
"context_limit": 200000,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -65,52 +64,3 @@ func TestParseMCPFromJSONMissingKey(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Nil(t, servers)
|
assert.Nil(t, servers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProvidersAsMapHonorsPerModelLimits(t *testing.T) {
|
|
||||||
p := &canonical.Profile{
|
|
||||||
Gateway: canonical.Gateway{URL: "https://gw.example.com/v1", Token: "t"},
|
|
||||||
Models: []canonical.Model{
|
|
||||||
{ID: "prov/big", Context: 262144, Output: 65536},
|
|
||||||
{ID: "prov/default"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
models := ProvidersAsMap(p)[GatewayProviderKey(p.Gateway.URL)].(map[string]any)["models"].(map[string]any)
|
|
||||||
|
|
||||||
big := models["prov/big"].(map[string]any)["limit"].(map[string]any)
|
|
||||||
assert.Equal(t, 262144, big["context"], "explicit context override should win")
|
|
||||||
assert.Equal(t, 65536, big["output"], "explicit output override should win")
|
|
||||||
|
|
||||||
def := models["prov/default"].(map[string]any)["limit"].(map[string]any)
|
|
||||||
assert.Equal(t, 200000, def["context"], "unset model falls back to default context")
|
|
||||||
assert.Equal(t, 8192, def["output"], "unset model falls back to default output")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestProvidersAsCrushMapHonorsPerModelLimits(t *testing.T) {
|
|
||||||
p := &canonical.Profile{
|
|
||||||
Gateway: canonical.Gateway{URL: "https://gw.example.com/v1", Token: "t"},
|
|
||||||
Models: []canonical.Model{
|
|
||||||
{ID: "prov/big", Context: 262144, Output: 65536},
|
|
||||||
{ID: "prov/default"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
models := ProvidersAsCrushMap(p)[GatewayProviderKey(p.Gateway.URL)].(map[string]any)["models"].([]map[string]any)
|
|
||||||
|
|
||||||
assert.Equal(t, 262144, models[0]["context_window"], "explicit context override should win")
|
|
||||||
assert.Equal(t, 65536, models[0]["default_max_tokens"], "explicit output override should win")
|
|
||||||
assert.Equal(t, 200000, models[1]["context_window"], "unset model falls back to default context")
|
|
||||||
assert.Equal(t, 8192, models[1]["default_max_tokens"], "unset model falls back to default output")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGooseCustomProviderFileHonorsPerModelContext(t *testing.T) {
|
|
||||||
p := &canonical.Profile{
|
|
||||||
Gateway: canonical.Gateway{URL: "https://gw.example.com/v1", Token: "t"},
|
|
||||||
Models: []canonical.Model{{ID: "big", Context: 262144}, {ID: "default"}},
|
|
||||||
}
|
|
||||||
body, _ := GooseCustomProviderFile(p)
|
|
||||||
var entry map[string]any
|
|
||||||
require.NoError(t, json.Unmarshal(body, &entry))
|
|
||||||
models := entry["models"].([]any)
|
|
||||||
|
|
||||||
assert.Equal(t, float64(262144), models[0].(map[string]any)["context_limit"], "explicit context override should win")
|
|
||||||
assert.Equal(t, float64(200000), models[1].(map[string]any)["context_limit"], "unset model falls back to default context")
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ func zedLanguageModels(p *canonical.Profile) map[string]any {
|
|||||||
for _, m := range p.Models {
|
for _, m := range p.Models {
|
||||||
me := map[string]any{
|
me := map[string]any{
|
||||||
"name": m.ID,
|
"name": m.ID,
|
||||||
"max_tokens": m.ContextLimit(),
|
"max_tokens": 200000,
|
||||||
"capabilities": map[string]any{
|
"capabilities": map[string]any{
|
||||||
"tools": true,
|
"tools": true,
|
||||||
"images": false,
|
"images": false,
|
||||||
|
|||||||
@@ -63,25 +63,6 @@ func TestZedRenderProducesExpectedTargets(t *testing.T) {
|
|||||||
assert.NotContains(t, parsed, "context_servers")
|
assert.NotContains(t, parsed, "context_servers")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestZedRenderHonorsPerModelContext(t *testing.T) {
|
|
||||||
home := t.TempDir()
|
|
||||||
b := bundle()
|
|
||||||
b.Profile.Models = []canonical.Model{{ID: "big", Context: 262144}}
|
|
||||||
|
|
||||||
fs, err := New(WithHome(home)).Render(b)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
seen := map[string]adapter.File{}
|
|
||||||
fs.ForEach(func(f adapter.File) { seen[f.Dest] = f })
|
|
||||||
cfgDest := filepath.Join(home, ".config", "zed", "settings.json")
|
|
||||||
require.Contains(t, seen, cfgDest)
|
|
||||||
|
|
||||||
var parsed map[string]any
|
|
||||||
require.NoError(t, json.Unmarshal(seen[cfgDest].Content, &parsed))
|
|
||||||
models := parsed["language_models"].(map[string]any)["openai_compatible"].(map[string]any)["hs-llmgw-example-com"].(map[string]any)["available_models"].([]any)
|
|
||||||
assert.Equal(t, float64(262144), models[0].(map[string]any)["max_tokens"], "explicit context override should win")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestZedRenderMergesExistingKeys(t *testing.T) {
|
func TestZedRenderMergesExistingKeys(t *testing.T) {
|
||||||
home := t.TempDir()
|
home := t.TempDir()
|
||||||
base := filepath.Join(home, ".config", "zed")
|
base := filepath.Join(home, ".config", "zed")
|
||||||
|
|||||||
@@ -35,33 +35,6 @@ type Upstream struct {
|
|||||||
type Model struct {
|
type Model struct {
|
||||||
ID string `yaml:"id"`
|
ID string `yaml:"id"`
|
||||||
Alias string `yaml:"alias,omitempty"`
|
Alias string `yaml:"alias,omitempty"`
|
||||||
// Context and Output are optional per-model limit overrides (tokens). When
|
|
||||||
// unset (0), harnesses fall back to DefaultContextLimit / DefaultOutputLimit.
|
|
||||||
Context int `yaml:"context,omitempty"`
|
|
||||||
Output int `yaml:"output,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default per-model limits, applied by harnesses that surface context/output
|
|
||||||
// limits when a Model doesn't specify its own.
|
|
||||||
const (
|
|
||||||
DefaultContextLimit = 200000
|
|
||||||
DefaultOutputLimit = 8192
|
|
||||||
)
|
|
||||||
|
|
||||||
// ContextLimit returns the model's context window, or DefaultContextLimit if unset.
|
|
||||||
func (m Model) ContextLimit() int {
|
|
||||||
if m.Context > 0 {
|
|
||||||
return m.Context
|
|
||||||
}
|
|
||||||
return DefaultContextLimit
|
|
||||||
}
|
|
||||||
|
|
||||||
// OutputLimit returns the model's max output tokens, or DefaultOutputLimit if unset.
|
|
||||||
func (m Model) OutputLimit() int {
|
|
||||||
if m.Output > 0 {
|
|
||||||
return m.Output
|
|
||||||
}
|
|
||||||
return DefaultOutputLimit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type MCPRegistry struct {
|
type MCPRegistry struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user