Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FilePart implement for ContentPart to support chat with file #1053

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions llms/generatecontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func ImageURLWithDetailPart(url string, detail string) ImageURLContent {
}
}

// FilePart creates a new File from the given MIME type and URL.
func FilePart(mime, url string) FileContent {
return FileContent{
MIMEType: mime,
URL: url,
}
}

// ContentPart is an interface all parts of content have to implement.
type ContentPart interface {
isPart()
Expand Down Expand Up @@ -86,6 +94,18 @@ func (bc BinaryContent) String() string {

func (BinaryContent) isPart() {}

// FileContent is content holding file url with a MIME type.
type FileContent struct {
MIMEType string
URL string
}

func (fc FileContent) String() string {
return fc.URL
}

func (FileContent) IsPart() {}

// FunctionCall is the name and arguments of a function call.
type FunctionCall struct {
// The name of the function to call.
Expand Down