mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-14 20:54:30 +08:00
@@ -102,12 +102,13 @@ func TestLLM_Invoke_OutputStructure_ValidFirstTry(t *testing.T) {
|
||||
Model: "echo",
|
||||
}}
|
||||
withStubInvoker(t, stub)
|
||||
ctx := t.Context()
|
||||
|
||||
c := NewLLMComponent(LLMParam{
|
||||
ModelID: "echo",
|
||||
OutputStructure: map[string]any{"name": "", "age": 0},
|
||||
})
|
||||
out, err := c.Invoke(context.Background(), nil, map[string]any{"user_prompt": "who?"})
|
||||
out, err := c.Invoke(ctx, nil, map[string]any{"user_prompt": "who?"})
|
||||
if err != nil {
|
||||
t.Fatalf("Invoke: %v", err)
|
||||
}
|
||||
@@ -136,12 +137,13 @@ func TestLLM_Invoke_OutputStructure_RetryOnInvalid(t *testing.T) {
|
||||
onCall: func() { calls++ },
|
||||
}
|
||||
withStubInvoker(t, inv)
|
||||
ctx := t.Context()
|
||||
|
||||
c := NewLLMComponent(LLMParam{
|
||||
ModelID: "echo",
|
||||
OutputStructure: map[string]any{"name": ""},
|
||||
})
|
||||
out, err := c.Invoke(context.Background(), nil, map[string]any{"user_prompt": "who?"})
|
||||
out, err := c.Invoke(ctx, nil, map[string]any{"user_prompt": "who?"})
|
||||
if err != nil {
|
||||
t.Fatalf("Invoke: %v", err)
|
||||
}
|
||||
@@ -173,12 +175,13 @@ func TestLLM_Invoke_OutputStructure_RetryStillFails(t *testing.T) {
|
||||
onCall: func() { calls++ },
|
||||
}
|
||||
withStubInvoker(t, inv)
|
||||
ctx := t.Context()
|
||||
|
||||
c := NewLLMComponent(LLMParam{
|
||||
ModelID: "echo",
|
||||
OutputStructure: map[string]any{"x": 0},
|
||||
})
|
||||
out, err := c.Invoke(context.Background(), nil, map[string]any{"user_prompt": "go"})
|
||||
out, err := c.Invoke(ctx, nil, map[string]any{"user_prompt": "go"})
|
||||
if err != nil {
|
||||
t.Fatalf("Invoke should not error on parse failure: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user