mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-08 07:11:06 +00:00
27 lines
789 B
Go
27 lines
789 B
Go
package common
|
|
|
|
import (
|
|
goopenai "github.com/sashabaranov/go-openai"
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestNormalizeMessages(t *testing.T) {
|
|
msgs := []*Message{
|
|
{Role: goopenai.ChatMessageRoleUser, Content: "Hello"},
|
|
{Role: goopenai.ChatMessageRoleAssistant, Content: "Hi there!"},
|
|
{Role: goopenai.ChatMessageRoleUser, Content: ""},
|
|
{Role: goopenai.ChatMessageRoleUser, Content: ""},
|
|
{Role: goopenai.ChatMessageRoleUser, Content: "How are you?"},
|
|
}
|
|
|
|
expected := []*Message{
|
|
{Role: goopenai.ChatMessageRoleUser, Content: "Hello"},
|
|
{Role: goopenai.ChatMessageRoleAssistant, Content: "Hi there!"},
|
|
{Role: goopenai.ChatMessageRoleUser, Content: "How are you?"},
|
|
}
|
|
|
|
actual := NormalizeMessages(msgs, "default")
|
|
assert.Equal(t, expected, actual)
|
|
}
|