mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-09-08 10:14:35 +08:00
fix[go]: support retrieval kb in agent chat (#16944)
### Summary
As title
- [x] fix tool & component `Retrieval KB`
- [x] fix agent cannot use `Retrieval KB` in agent chat
#### Main cause
Model provider do not set up:
```Go
if chatModelConfig.Tools != nil {
reqBody["tools"] = chatModelConfig.Tools
}
```
#### Working Now
<img width="3774" height="2128" alt="image"
src="https://github.com/user-attachments/assets/400a349d-0211-43e5-a7ec-7a014acf77a6"
/>
```
____________________________________
< This PR takes me all day to do it. >
------------------------------------
\
\ (\__/)
(•ㅅ•)
/ づ
```
This commit is contained in:
@@ -112,6 +112,41 @@ func TestMessage_RuntimeContentInput(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessage_FormalizedContentFallback(t *testing.T) {
|
||||
c, _ := NewMessageComponent(nil)
|
||||
state := canvas.NewCanvasState("run-5", "task-5")
|
||||
ctx := withStateForTest(context.Background(), state)
|
||||
|
||||
out, err := c.Invoke(ctx, map[string]any{
|
||||
"formalized_content": "retrieved answer",
|
||||
"_created_time": "2026-07-15T00:00:00Z",
|
||||
"_elapsed_time": 0.01,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Invoke: %v", err)
|
||||
}
|
||||
if got, _ := out["content"].(string); got != "retrieved answer" {
|
||||
t.Errorf("content: got %q, want %q", got, "retrieved answer")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessage_SingleStringFallback(t *testing.T) {
|
||||
c, _ := NewMessageComponent(nil)
|
||||
state := canvas.NewCanvasState("run-6", "task-6")
|
||||
ctx := withStateForTest(context.Background(), state)
|
||||
|
||||
out, err := c.Invoke(ctx, map[string]any{
|
||||
"value": "single upstream text",
|
||||
"_elapsed_time": 0.01,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Invoke: %v", err)
|
||||
}
|
||||
if got, _ := out["content"].(string); got != "single upstream text" {
|
||||
t.Errorf("content: got %q, want %q", got, "single upstream text")
|
||||
}
|
||||
}
|
||||
|
||||
// withStateForTest is a thin alias for canvas.WithState kept for
|
||||
// readability at the test call sites (also defined in begin_test.go).
|
||||
// Same package → same symbol; defining it twice is a compile error,
|
||||
|
||||
Reference in New Issue
Block a user