mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-06 21:11:50 +08:00
feat: 接入 Jev 拦截判定模型
Add TypeSafe System One as an isolated intercept judge backend.
This commit is contained in:
1 parent
0ed68d9143
commit
b0e25d766f
18 files changed
+552
-32
No files matched your search
+15
-1
@@ -30,7 +30,10 @@ import (
|
||||
|
||||
// Config describes the LLM backend resolved from the environment.
|
||||
type Config struct {
|
||||
Format llm.Format
|
||||
Format llm.Format
|
||||
// Jev marks the TypeSafe System One judge protocol. It must never be sent
|
||||
// through the chat/completions provider path.
|
||||
Jev bool
|
||||
BaseURL string
|
||||
APIKey string
|
||||
Model string
|
||||
@@ -204,6 +207,11 @@ func ConfigFrom(provider, model, baseURL, apiKey, proxy string) Config {
|
||||
Stream: true, // 默认流式;调用方按 profile 覆盖
|
||||
}
|
||||
switch strings.TrimSpace(provider) {
|
||||
case "jev":
|
||||
c.Jev = true
|
||||
if c.Model == "" {
|
||||
c.Model = "jev-latest"
|
||||
}
|
||||
case "openai":
|
||||
c.Format = llm.FormatOpenAI
|
||||
// provider appends "/chat/completions"; tolerate a full endpoint URL.
|
||||
@@ -241,6 +249,9 @@ func isFalsy(s string) bool {
|
||||
|
||||
// Provider returns the short provider name ("anthropic"/"openai").
|
||||
func (c Config) Provider() string {
|
||||
if c.Jev {
|
||||
return "jev"
|
||||
}
|
||||
switch c.Format {
|
||||
case llm.FormatOpenAI:
|
||||
return "openai"
|
||||
@@ -259,6 +270,9 @@ func (c Config) NewProvider() (llm.Provider, error) {
|
||||
// NewProviderWithLimiter reuses quota history across provider rebuilds. Callers
|
||||
// sharing a profile must retain the same limiter outside their provider cache.
|
||||
func (c Config) NewProviderWithLimiter(limiter *RequestLimiter) (llm.Provider, error) {
|
||||
if c.Jev {
|
||||
return nil, fmt.Errorf("Jev System One 仅可用于拦截判定模型,不能作为聊天 provider")
|
||||
}
|
||||
client, err := quotaAwareHTTPClient(c.Proxy, c.SessionHeaderKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package agent
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestJevConfigCannotBuildChatProvider(t *testing.T) {
|
||||
c := ConfigFrom("jev", "", "", "key", "")
|
||||
if !c.Jev || c.Provider() != "jev" {
|
||||
t.Fatalf("unexpected Jev config: %+v", c)
|
||||
}
|
||||
if _, err := c.NewProvider(); err == nil {
|
||||
t.Fatal("Jev config must be rejected by chat provider construction")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user