mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-14 20:54:30 +08:00
@@ -35,7 +35,9 @@ func TestLLM_ForwardsTopP(t *testing.T) {
|
||||
ModelID: "echo",
|
||||
TopP: &topP,
|
||||
})
|
||||
if _, err := c.Invoke(context.Background(), nil, map[string]any{"user_prompt": "hi"}); err != nil {
|
||||
ctx := t.Context()
|
||||
|
||||
if _, err := c.Invoke(ctx, nil, map[string]any{"user_prompt": "hi"}); err != nil {
|
||||
t.Fatalf("Invoke: %v", err)
|
||||
}
|
||||
if stub.calls != 1 {
|
||||
@@ -57,9 +59,11 @@ func TestLLM_ForwardsTopP(t *testing.T) {
|
||||
func TestLLM_TopPFromInputs(t *testing.T) {
|
||||
stub := &stubInvoker{resp: &ChatInvokeResponse{Content: "ok", Model: "echo"}}
|
||||
withStubInvoker(t, stub)
|
||||
ctx := t.Context()
|
||||
|
||||
c := NewLLMComponent(LLMParam{ModelID: "echo"})
|
||||
if _, err := c.Invoke(context.Background(), nil, map[string]any{
|
||||
|
||||
if _, err := c.Invoke(ctx, nil, map[string]any{
|
||||
"user_prompt": "hi",
|
||||
"top_p": 0.7,
|
||||
}); err != nil {
|
||||
@@ -78,9 +82,10 @@ func TestLLM_TopPFromInputs(t *testing.T) {
|
||||
func TestLLM_NoTopPByDefault(t *testing.T) {
|
||||
stub := &stubInvoker{resp: &ChatInvokeResponse{Content: "ok", Model: "echo"}}
|
||||
withStubInvoker(t, stub)
|
||||
ctx := t.Context()
|
||||
|
||||
c := NewLLMComponent(LLMParam{ModelID: "echo"})
|
||||
if _, err := c.Invoke(context.Background(), nil, map[string]any{"user_prompt": "hi"}); err != nil {
|
||||
if _, err := c.Invoke(ctx, nil, map[string]any{"user_prompt": "hi"}); err != nil {
|
||||
t.Fatalf("Invoke: %v", err)
|
||||
}
|
||||
if stub.captured == nil {
|
||||
@@ -128,6 +133,7 @@ func TestAgentParam_ForwardsTopP(t *testing.T) {
|
||||
}
|
||||
return &schema.Message{Content: "ok"}, nil
|
||||
})
|
||||
ctx := t.Context()
|
||||
|
||||
topP := 0.5
|
||||
c := NewAgentComponent(AgentParam{
|
||||
@@ -135,7 +141,7 @@ func TestAgentParam_ForwardsTopP(t *testing.T) {
|
||||
TopP: &topP,
|
||||
MaxRounds: 1,
|
||||
})
|
||||
if _, err := c.Invoke(context.Background(), nil, map[string]any{"user_prompt": "hi"}); err != nil {
|
||||
if _, err := c.Invoke(ctx, nil, map[string]any{"user_prompt": "hi"}); err != nil {
|
||||
t.Fatalf("Invoke: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -148,9 +154,10 @@ func TestAgent_TopPFromInputs(t *testing.T) {
|
||||
}
|
||||
return &schema.Message{Content: "ok"}, nil
|
||||
})
|
||||
ctx := t.Context()
|
||||
|
||||
c := NewAgentComponent(AgentParam{ModelID: "echo", MaxRounds: 1})
|
||||
if _, err := c.Invoke(context.Background(), nil, map[string]any{
|
||||
if _, err := c.Invoke(ctx, nil, map[string]any{
|
||||
"user_prompt": "hi",
|
||||
"top_p": 0.42,
|
||||
}); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user