-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #549 from tmc/llms-add-helpers
llms: Add convenience helper for text parts
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package llms | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/tmc/langchaingo/schema" | ||
) | ||
|
||
func TestTextParts(t *testing.T) { | ||
t.Parallel() | ||
type args struct { | ||
role schema.ChatMessageType | ||
parts []string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want MessageContent | ||
}{ | ||
{"basics", args{schema.ChatMessageTypeHuman, []string{"a", "b", "c"}}, MessageContent{ | ||
Role: schema.ChatMessageTypeHuman, | ||
Parts: []ContentPart{ | ||
TextContent{Text: "a"}, | ||
TextContent{Text: "b"}, | ||
TextContent{Text: "c"}, | ||
}, | ||
}}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
if got := TextParts(tt.args.role, tt.args.parts...); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("TextParts() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |