- Introduced `image_generate` tool for generating images from text prompts, with options for specifying output file paths and image dimensions. - Updated `image_read` functionality to allow optional provider specification for enhanced image analysis. - Implemented new `GenerateImage` method in the LLM API for seamless integration of image generation capabilities. - Enhanced documentation to include detailed usage examples for both image reading and generation tools. - Updated tests to validate new image generation features and ensure robust functionality across image tools.
35 lines
778 B
Go
35 lines
778 B
Go
package image
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/yaoapp/gou/process"
|
|
)
|
|
|
|
func TestGenerateHandler_NoPrompt(t *testing.T) {
|
|
proc := &process.Process{
|
|
Args: []interface{}{""},
|
|
}
|
|
result := GenerateHandler(proc)
|
|
m, ok := result.(map[string]interface{})
|
|
if !ok {
|
|
t.Fatal("expected map result")
|
|
}
|
|
if errMsg, _ := m["error"].(string); errMsg != "prompt is required" {
|
|
t.Errorf("expected 'prompt is required', got %q", errMsg)
|
|
}
|
|
}
|
|
|
|
func TestGenerateHandler_NoAuth(t *testing.T) {
|
|
proc := &process.Process{
|
|
Args: []interface{}{"A sunset", "", "1024x1024"},
|
|
}
|
|
result := GenerateHandler(proc)
|
|
m, ok := result.(map[string]interface{})
|
|
if !ok {
|
|
t.Fatal("expected map result")
|
|
}
|
|
if _, hasErr := m["error"]; !hasErr {
|
|
t.Error("expected error when no auth info")
|
|
}
|
|
}
|