Correct artifact file and empty input handling
This commit is contained in:
16
types.go
16
types.go
@@ -243,8 +243,8 @@ type ArtifactRef struct {
|
||||
// URI is the file path for ArtifactRefFile and optional provenance metadata
|
||||
// for ArtifactRefInline.
|
||||
URI string
|
||||
// Body is the content for ArtifactRefInline and is ignored for
|
||||
// ArtifactRefFile.
|
||||
// Body is the content for ArtifactRefInline, where an empty value is valid,
|
||||
// and is ignored for ArtifactRefFile.
|
||||
Body string
|
||||
}
|
||||
|
||||
@@ -700,8 +700,12 @@ type GenerateResponse struct {
|
||||
|
||||
// File returns a file-backed artifact reference whose URI is path.
|
||||
//
|
||||
// The default artifact reader opens path as a caller-selected operating-system
|
||||
// path without restricting it to an application root or imposing a size limit.
|
||||
// The default artifact reader accepts path only when it resolves to a regular
|
||||
// operating-system file, checking that condition before and after opening it.
|
||||
// It reads synchronously in bounded chunks and checks context cancellation
|
||||
// before opening, before and after each read, and before returning the
|
||||
// artifact; it cannot interrupt a filesystem operation already in progress.
|
||||
// It does not restrict path to an application root or impose a size limit.
|
||||
// Applications accepting untrusted paths must validate them before calling
|
||||
// Promptkit or use [WithArtifactReader] to enforce application policy.
|
||||
func File(path string) ArtifactRef {
|
||||
@@ -709,13 +713,13 @@ func File(path string) ArtifactRef {
|
||||
}
|
||||
|
||||
// Inline returns an inline artifact reference whose Body is body and whose URI
|
||||
// is empty.
|
||||
// is empty. An empty body is a valid, explicitly supplied input.
|
||||
func Inline(body string) ArtifactRef {
|
||||
return ArtifactRef{Type: ArtifactRefInline, Body: body}
|
||||
}
|
||||
|
||||
// InlineWithURI returns an inline artifact reference with body content and uri
|
||||
// provenance metadata.
|
||||
// provenance metadata. An empty body is a valid, explicitly supplied input.
|
||||
func InlineWithURI(uri string, body string) ArtifactRef {
|
||||
return ArtifactRef{Type: ArtifactRefInline, URI: uri, Body: body}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user