Documentation
¶
Index ¶
- func Data(name string, data []byte) (llm.Resource, error)
- func JSON(name string, v any) (llm.Resource, error)
- func Must[V string | json.RawMessage | []byte](name string, value V) llm.Resource
- func Read(r io.Reader) (llm.Resource, error)
- func Text(name, content string) (llm.Resource, error)
- func Unmarshal(data []byte) (llm.Resource, error)
- func WithDescription(description string, r llm.Resource) llm.Resource
- func WithNamespace(namespace string, r llm.Resource) llm.Resource
- func WithURI(uri string, r llm.Resource) llm.Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Data ¶
Data returns a new in-memory resource for the given raw bytes. The MIME type is resolved by content sniffing first; if the sniffed type is application/octet-stream and name has an extension, the extension is used as a fallback. If name contains path separators or an extension, the bare base name (without extension) is used as the resource identifier.
func JSON ¶
JSON returns a new in-memory JSON resource with the given name. If v is already a json.RawMessage it is used directly; otherwise v is marshalled to JSON. Name must be a non-empty identifier.
func Must ¶
Must creates a resource from name and value, panicking on error. V may be string (text resource), json.RawMessage (JSON resource), or []byte (data resource).
func Read ¶
Read reads all bytes from r and returns a resource. If r is an *os.File its path is used to derive the name and MIME type, exactly as Data() does. For other readers r must be an io.Reader with discoverable content only; the name defaults to "data" and the MIME type is content-sniffed.
func Text ¶
Text returns a new in-memory text resource with the given name and content. The URI scheme is "text:" and the MIME type is "text/plain". Name must be a non-empty identifier.
func Unmarshal ¶
Unmarshal decodes a JSON-encoded resource (as produced by MarshalJSON) back into an llm.Resource. The MIME type field determines the concrete type:
- "text/plain" → text resource
- "application/json" → JSON resource
- anything else → binary data resource
If the JSON contains a non-empty description the result is wrapped with WithDescription so that Description() returns the stored value.
func WithDescription ¶
WithDescription returns r with its description replaced by the given value.
func WithNamespace ¶
WithNamespace returns r with its name replaced by "namespace.r.Name()".
Types ¶
This section is empty.