Skip to content

Commit f8152d5

Browse files
refactor(ai): simplify runtime and RAG/tools integration and add unit tests (#1433)
* [refactor(runtime)] redesign component registry and loading * [fix(config)] apply defaults for composite schemas * [fix(server)] bind default host to all interfaces * [docs(paths)] normalize local project references * [chore(repo)] clean local workflow artifacts * [refactor(rag)]modularize subcomponents and option pipeline * [refactor(tools)]bind tool managers to runtime components * [feat(models)]register actions and refresh default embeddings * [feat(agent)]simplify react stages and align prompt contracts * [docs(ai)]refresh readme/proposals/todo/checklist assets * [docs(ai)] delete redundant docs and link wiki website
1 parent 171b54b commit f8152d5

65 files changed

Lines changed: 2588 additions & 1618 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ai/.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
.env
77

88
reference
9-
.qoder
9+
.qoder
10+
AGENTS.md
11+
# Temporary ignore for vibe-coding docs
12+
.claude/
13+
.spec-workflow/
14+
.commenting-guidelines.md
15+
CLAUDE.md

ai/README.md

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
1-
# dubbo-admin-ai
2-
## Introduction
1+
# Dubbo Admin AI
32

4-
This project is an intelligent agent's server for dubbo-admin.
3+
Dubbo Admin AI 是面向 Dubbo Admin 场景的智能运维服务模块,用于通过 AI 对话辅助排障、分析与治理决策。
54

6-
7-
## Startup
8-
1. Set your API Keys in the `.env` file or set them as environment variables
9-
```shell
10-
# .env_example
11-
PINECONE_API_KEY=your_pinecone_api_key
12-
DASHSCOPE_API_KEY=your_dashscope_api_key
13-
COHERE_API_KEY=your_cohere_api_key
14-
SILICONFLOW_API_KEY=your_siliconflow_api_key
15-
GEMINI_API_KEY=your_gemini_api_key
16-
```
17-
18-
2. Run the server
19-
```shell
20-
go run main.go --mode dev --env your_env_file_path --port 8888
21-
```
22-
23-
## Build and Run
24-
```shell
25-
mkdir build
26-
cd build
27-
go build -o dubbo-admin-ai ../
28-
29-
./dubbo-admin-ai --mode prod --env your_env_file_path --port 8888
30-
```
5+
项目 wiki: https://stringl1l1l1l.github.io/dubbo-admin-ai-wiki/

ai/TEST_CHECKLIST_V7.md

Lines changed: 0 additions & 250 deletions
This file was deleted.

ai/cmd/index.go

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
compRag "dubbo-admin-ai/component/rag"
66
appconfig "dubbo-admin-ai/config"
7+
"dubbo-admin-ai/runtime"
78
"flag"
89
"fmt"
910
"log"
@@ -17,6 +18,7 @@ import (
1718
"github.com/firebase/genkit/go/plugins/googlegenai"
1819
"github.com/firebase/genkit/go/plugins/pinecone"
1920
"github.com/openai/openai-go/option"
21+
"gopkg.in/yaml.v3"
2022
)
2123

2224
type IndexCommand struct {
@@ -116,7 +118,7 @@ func executeIndexing(cmd *IndexCommand) error {
116118
// Build-time target index selection: default to directory name for this CLI
117119
targetIndex := getNamespace("", cmd.Directory)
118120

119-
sys, err := compRag.BuildRAGFromSpec(ctx, g, cfg)
121+
sys, err := buildRAGSystem(g, cfg)
120122
if err != nil {
121123
return fmt.Errorf("failed to build RAG system: %w", err)
122124
}
@@ -175,3 +177,41 @@ func loadRAGConfig(configPath string) (*compRag.RAGSpec, error) {
175177

176178
return &cfg, nil
177179
}
180+
181+
func buildRAGSystem(g *genkit.Genkit, cfg *compRag.RAGSpec) (*compRag.RAG, error) {
182+
if g == nil {
183+
return nil, fmt.Errorf("genkit registry is nil")
184+
}
185+
if cfg == nil {
186+
return nil, fmt.Errorf("rag config is nil")
187+
}
188+
189+
var specNode yaml.Node
190+
if err := specNode.Encode(cfg); err != nil {
191+
return nil, fmt.Errorf("failed to encode rag config: %w", err)
192+
}
193+
194+
compRaw, err := compRag.RAGFactory(&specNode)
195+
if err != nil {
196+
return nil, fmt.Errorf("failed to create rag component: %w", err)
197+
}
198+
199+
ragComp, ok := compRaw.(*compRag.RAGComponent)
200+
if !ok {
201+
return nil, fmt.Errorf("invalid rag component type: %T", compRaw)
202+
}
203+
204+
rt := runtime.NewRuntime()
205+
rt.SetGenkitRegistry(g)
206+
if err := ragComp.Validate(); err != nil {
207+
return nil, fmt.Errorf("failed to validate rag component: %w", err)
208+
}
209+
if err := ragComp.Init(rt); err != nil {
210+
return nil, fmt.Errorf("failed to init rag component: %w", err)
211+
}
212+
if ragComp.Rag == nil {
213+
return nil, fmt.Errorf("rag system is not initialized")
214+
}
215+
216+
return ragComp.Rag, nil
217+
}

0 commit comments

Comments
 (0)