GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(judge): wire verdict cache in gateway, relay, and demo · majorcontext/keep@51052eb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cmd
    • keep-llm-gateway
      • main.go
    • keep-mcp-relay
      • main.go
  • examples/judge-demo
    • demo.sh
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cmd/keep-llm-gateway/main.go‎

Copy file name to clipboardExpand all lines: cmd/keep-llm-gateway/main.go
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/majorcontext/keep/internal/audit"
1717
"github.com/majorcontext/keep/internal/gateway"
1818
gwconfig "github.com/majorcontext/keep/internal/gateway/config"
19+
"github.com/majorcontext/keep/judge"
1920
anthropicjudge "github.com/majorcontext/keep/judge/anthropic"
2021
openaijudge "github.com/majorcontext/keep/judge/openai"
2122
)
@@ -54,14 +55,16 @@ func main() {
5455
jopts = append(jopts, anthropicjudge.WithBaseURL(cfg.Judge.BaseURL))
5556
}
5657
p := anthropicjudge.New(apiKey, jopts...)
57-
engineOpts = append(engineOpts, keep.WithJudge(p.Judge))
58+
cached := judge.NewCache(p)
59+
engineOpts = append(engineOpts, keep.WithJudge(cached.Judge))
5860
case "openai":
5961
var jopts []openaijudge.Option
6062
if cfg.Judge.BaseURL != "" {
6163
jopts = append(jopts, openaijudge.WithBaseURL(cfg.Judge.BaseURL))
6264
}
6365
p := openaijudge.New(apiKey, jopts...)
64-
engineOpts = append(engineOpts, keep.WithJudge(p.Judge))
66+
cached := judge.NewCache(p)
67+
engineOpts = append(engineOpts, keep.WithJudge(cached.Judge))
6568
}
6669
}
6770
}
Collapse file

‎cmd/keep-mcp-relay/main.go‎

Copy file name to clipboardExpand all lines: cmd/keep-mcp-relay/main.go
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/majorcontext/keep/internal/relay"
1717
relayconfig "github.com/majorcontext/keep/internal/relay/config"
1818
"github.com/majorcontext/keep/internal/relay/mcp"
19+
"github.com/majorcontext/keep/judge"
1920
anthropicjudge "github.com/majorcontext/keep/judge/anthropic"
2021
openaijudge "github.com/majorcontext/keep/judge/openai"
2122
)
@@ -54,14 +55,16 @@ func main() {
5455
jopts = append(jopts, anthropicjudge.WithBaseURL(cfg.Judge.BaseURL))
5556
}
5657
p := anthropicjudge.New(apiKey, jopts...)
57-
engineOpts = append(engineOpts, keep.WithJudge(p.Judge))
58+
cached := judge.NewCache(p)
59+
engineOpts = append(engineOpts, keep.WithJudge(cached.Judge))
5860
case "openai":
5961
var jopts []openaijudge.Option
6062
if cfg.Judge.BaseURL != "" {
6163
jopts = append(jopts, openaijudge.WithBaseURL(cfg.Judge.BaseURL))
6264
}
6365
p := openaijudge.New(apiKey, jopts...)
64-
engineOpts = append(engineOpts, keep.WithJudge(p.Judge))
66+
cached := judge.NewCache(p)
67+
engineOpts = append(engineOpts, keep.WithJudge(cached.Judge))
6568
}
6669
}
6770
}
Collapse file

‎examples/judge-demo/demo.sh‎

Copy file name to clipboardExpand all lines: examples/judge-demo/demo.sh
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ for line in open('$1'):
8686
verdict = j.get('verdict', '?')
8787
reason = j.get('reason', '')
8888
ms = j.get('latency_ms', 0)
89+
cached = j.get('cached', False)
90+
cache_tag = ' (cached)' if cached else ''
8991
vc = '\033[32m' if verdict == 'allow' else '\033[31m'
9092
if len(reason) > 100:
9193
reason = reason[:100] + '...'
92-
print(f' {magenta}\u2728 {model}{reset}: {vc}{verdict}{reset} ({ms}ms) \u2014 {dim}{reason}{reset}')
94+
print(f' {magenta}\u2728 {model}{reset}: {vc}{verdict}{reset} ({ms}ms){cache_tag} \u2014 {dim}{reason}{reset}')
9395
except: pass
9496
" 2>/dev/null
9597
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.