Skip to content

Commit a01efcb

Browse files
committed
feat: support plugins and llm shield
1 parent 303fffe commit a01efcb

File tree

15 files changed

+660
-4
lines changed

15 files changed

+660
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
go.work
2323

2424
.idea/
25+
.trae
2526
agent/.env
2627
examples/quickstart/config.yaml

apps/a2a_app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (a *agentkitA2AServerApp) SetupRouters(router *mux.Router, config *apps.Run
9696
SessionService: config.SessionService,
9797
ArtifactService: config.ArtifactService,
9898
MemoryService: config.MemoryService,
99+
PluginConfig: config.PluginConfig,
99100
},
100101
})
101102
reqHandler := a2asrv.NewHandler(executor, config.A2AOptions...)

apps/agentkit_server_app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (a *agentkitServerApp) SetupRouters(router *mux.Router, config *apps.RunCon
9393
MemoryService: config.MemoryService,
9494
AgentLoader: config.AgentLoader,
9595
A2AOptions: config.A2AOptions,
96+
PluginConfig: config.PluginConfig,
9697
}
9798

9899
// setup webui routers

apps/basic_app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"google.golang.org/adk/agent"
2525
"google.golang.org/adk/artifact"
2626
"google.golang.org/adk/memory"
27+
"google.golang.org/adk/runner"
2728
"google.golang.org/adk/session"
2829
)
2930

@@ -33,6 +34,7 @@ type RunConfig struct {
3334
MemoryService memory.Service
3435
AgentLoader agent.Loader
3536
A2AOptions []a2asrv.RequestHandlerOption
37+
PluginConfig runner.PluginConfig
3638
}
3739

3840
type ApiConfig struct {

apps/simple_app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func (app *agentkitSimpleApp) SetupRouters(router *mux.Router, config *apps.RunC
7878
SessionService: sessionService,
7979
ArtifactService: config.ArtifactService,
8080
MemoryService: config.MemoryService,
81+
PluginConfig: config.PluginConfig,
8182
})
8283
if err != nil {
8384
return fmt.Errorf("new runner error: %w", err)

auth/veauth/utils.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ package veauth
1616

1717
import (
1818
"encoding/json"
19+
"log"
1920
"os"
2021
"strings"
2122

2223
"github.com/volcengine/veadk-go/common"
24+
"github.com/volcengine/veadk-go/configs"
25+
"github.com/volcengine/veadk-go/utils"
2326
)
2427

2528
type VeIAMCredential struct {
@@ -50,3 +53,20 @@ func RefreshAKSK(accessKey string, secretKey string) (VeIAMCredential, error) {
5053
}
5154
return GetCredentialFromVeFaaSIAM()
5255
}
56+
57+
func GetAuthInfo() (ak, sk, sessionToken string) {
58+
ak = utils.GetEnvWithDefault(common.VOLCENGINE_ACCESS_KEY, configs.GetGlobalConfig().Volcengine.AK)
59+
sk = utils.GetEnvWithDefault(common.VOLCENGINE_SECRET_KEY, configs.GetGlobalConfig().Volcengine.SK)
60+
61+
if strings.TrimSpace(ak) == "" || strings.TrimSpace(sk) == "" {
62+
iam, err := GetCredentialFromVeFaaSIAM()
63+
if err != nil {
64+
log.Printf("GetAuthInfo error: %s\n", err.Error())
65+
} else {
66+
ak = iam.AccessKeyID
67+
sk = iam.SecretAccessKey
68+
sessionToken = iam.SessionToken
69+
}
70+
}
71+
return
72+
}

common/consts.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,11 @@ const (
8989
AGENTPILOT_API_KEY = "AGENTPILOT_API_KEY"
9090
AGENTPILOT_WORKSPACE_ID = "AGENTPILOT_WORKSPACE_ID"
9191
)
92+
93+
// LLM Shield
94+
const (
95+
TOOL_LLM_SHIELD_URL = "TOOL_LLM_SHIELD_URL"
96+
TOOL_LLM_SHIELD_REGION = "TOOL_LLM_SHIELD_REGION"
97+
TOOL_LLM_SHIELD_APP_ID = "TOOL_LLM_SHIELD_APP_ID"
98+
TOOL_LLM_SHIELD_API_KEY = "TOOL_LLM_SHIELD_API_KEY"
99+
)

common/defaults.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ const (
6969
DEFAULT_AGENTKIT_TOOL_SERVICE_CODE = "agentkit"
7070
)
7171

72+
// prompt pilot
7273
const (
7374
DEFAULT_AGENTPILOT_API_URL = "https://prompt-pilot.cn-beijing.volces.com"
7475
)
76+
77+
// LLM Shield
78+
const (
79+
DEFAULT_LLM_SHIELD_REGION = "cn-beijing"
80+
)

configs/configs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func SetupVeADKConfig() error {
6969
Tool: &BuiltinToolConfigs{
7070
MCPRouter: &MCPRouter{},
7171
RunCode: &RunCode{},
72+
LLMShield: &LLMShield{},
7273
},
7374
PromptPilot: &PromptPilotConfig{},
7475
TlsConfig: &TLSConfig{},

configs/tool.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ import (
2222
type BuiltinToolConfigs struct {
2323
MCPRouter *MCPRouter `yaml:"mcp_router"`
2424
RunCode *RunCode `yaml:"run_code"`
25+
LLMShield *LLMShield `yaml:"llm_shield"`
2526
}
2627

2728
func (b *BuiltinToolConfigs) MapEnvToConfig() {
2829
b.MCPRouter.MapEnvToConfig()
2930
b.RunCode.MapEnvToConfig()
31+
b.LLMShield.MapEnvToConfig()
3032
}
3133

3234
type MCPRouter struct {
@@ -52,3 +54,17 @@ func (r *RunCode) MapEnvToConfig() {
5254
r.ServiceCode = utils.GetEnvWithDefault(common.AGENTKIT_TOOL_SERVICE_CODE)
5355
r.Region = utils.GetEnvWithDefault(common.AGENTKIT_TOOL_REGION)
5456
}
57+
58+
type LLMShield struct {
59+
Url string `yaml:"url"`
60+
Region string `yaml:"region"`
61+
AppId string `yaml:"app_id"`
62+
ApiKey string `yaml:"api_key"`
63+
}
64+
65+
func (r *LLMShield) MapEnvToConfig() {
66+
r.Url = utils.GetEnvWithDefault(common.TOOL_LLM_SHIELD_URL)
67+
r.Region = utils.GetEnvWithDefault(common.TOOL_LLM_SHIELD_REGION)
68+
r.ApiKey = utils.GetEnvWithDefault(common.TOOL_LLM_SHIELD_API_KEY)
69+
r.AppId = utils.GetEnvWithDefault(common.TOOL_LLM_SHIELD_APP_ID)
70+
}

0 commit comments

Comments
 (0)