mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-15 05:04:27 +08:00
@@ -17,7 +17,6 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -285,10 +284,11 @@ func TestBuildMessagesWithImages_WithImages_UsesUserInputMultiContent(t *testing
|
||||
func TestLLM_Invoke_ForwardsImagesToInvoker(t *testing.T) {
|
||||
stub := &stubInvoker{resp: &ChatInvokeResponse{Content: "ok", Model: "echo"}}
|
||||
withStubInvoker(t, stub)
|
||||
ctx := t.Context()
|
||||
|
||||
uri := "data:image/png;base64,iVBORw0KGgo="
|
||||
c := NewLLMComponent(LLMParam{ModelID: "echo"})
|
||||
_, err := c.Invoke(context.Background(), nil, map[string]any{
|
||||
_, err := c.Invoke(ctx, nil, map[string]any{
|
||||
"user_prompt": "what is this?",
|
||||
"visual_files": []string{uri},
|
||||
})
|
||||
@@ -318,9 +318,10 @@ func TestLLM_Invoke_ForwardsImagesToInvoker(t *testing.T) {
|
||||
func TestLLM_Invoke_NoVisualFiles_BackwardCompat(t *testing.T) {
|
||||
stub := &stubInvoker{resp: &ChatInvokeResponse{Content: "ok", Model: "echo"}}
|
||||
withStubInvoker(t, stub)
|
||||
ctx := t.Context()
|
||||
|
||||
c := NewLLMComponent(LLMParam{ModelID: "echo"})
|
||||
_, err := c.Invoke(context.Background(), nil, map[string]any{
|
||||
_, err := c.Invoke(ctx, nil, map[string]any{
|
||||
"user_prompt": "hi",
|
||||
})
|
||||
if err != nil {
|
||||
@@ -347,10 +348,11 @@ func TestLLM_Invoke_NoVisualFiles_BackwardCompat(t *testing.T) {
|
||||
func TestLLM_Invoke_VisualFilesAsString(t *testing.T) {
|
||||
stub := &stubInvoker{resp: &ChatInvokeResponse{Content: "ok", Model: "echo"}}
|
||||
withStubInvoker(t, stub)
|
||||
ctx := t.Context()
|
||||
|
||||
uri := "data:image/jpeg;base64,/9j/4AAQ"
|
||||
c := NewLLMComponent(LLMParam{ModelID: "echo"})
|
||||
_, err := c.Invoke(context.Background(), nil, map[string]any{
|
||||
_, err := c.Invoke(ctx, nil, map[string]any{
|
||||
"user_prompt": "describe",
|
||||
"visual_files": "see " + uri,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user