Skip to content

Commit fb51cf6

Browse files
authored
rename IsPlainText -> IsText (#155)
to better match the other Part kinds.
1 parent 5d71e50 commit fb51cf6

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

go/ai/document.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewToolResponsePart(r *ToolResponse) *Part {
7272
}
7373

7474
// IsText reports whether the [Part] contains plain text.
75-
func (p *Part) IsPlainText() bool {
75+
func (p *Part) IsText() bool {
7676
return p.kind == partText
7777
}
7878

go/ai/document_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func TestDocumentFromText(t *testing.T) {
2929
t.Fatalf("got %d parts, want 1", len(d.Content))
3030
}
3131
p := d.Content[0]
32-
if !p.IsPlainText() {
33-
t.Errorf("IsPlainText() == %t, want %t", p.IsPlainText(), true)
32+
if !p.IsText() {
33+
t.Errorf("IsText() == %t, want %t", p.IsText(), true)
3434
}
3535
if got := p.Text(); got != data {
3636
t.Errorf("Data() == %q, want %q", got, data)

go/genkit/dotprompt/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (p *Prompt) RenderText(variables map[string]any) (string, error) {
3838
}
3939
var sb strings.Builder
4040
for _, part := range msgs[0].Content {
41-
if !part.IsPlainText() {
41+
if !part.IsText() {
4242
return "", errors.New("RenderText: multi-modal prompt can't be rendered as text")
4343
}
4444
sb.WriteString(part.Text())

go/genkit/dotprompt/render_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func TestRenderMessages(t *testing.T) {
198198
}
199199

200200
cmpPart := func(a, b *ai.Part) bool {
201-
if a.IsPlainText() != b.IsPlainText() {
201+
if a.IsText() != b.IsText() {
202202
return false
203203
}
204204
if a.Text() != b.Text() {

go/plugins/googleai/googleai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func convertParts(parts []*ai.Part) []genai.Part {
263263
// convertPart converts a *ai.Part to a genai.Part.
264264
func convertPart(p *ai.Part) genai.Part {
265265
switch {
266-
case p.IsPlainText():
266+
case p.IsText():
267267
return genai.Text(p.Text())
268268
case p.IsBlob():
269269
return genai.Blob{MIMEType: p.ContentType(), Data: []byte(p.Text())}

go/plugins/vertexai/vertexai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func convertParts(parts []*ai.Part) []genai.Part {
157157
// convertPart converts a *ai.Part to a genai.Part.
158158
func convertPart(p *ai.Part) genai.Part {
159159
switch {
160-
case p.IsPlainText():
160+
case p.IsText():
161161
return genai.Text(p.Text())
162162
default:
163163
return genai.Blob{MIMEType: p.ContentType(), Data: []byte(p.Text())}

0 commit comments

Comments
 (0)