Foundry.LlmResource¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r |
|||
r |
|||
r |
|||
r |
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Emitted when the resource has changed. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class Foundry.LlmResource(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
Abstract base class for LLM resources.
A resource represents external content that can be provided to an LLM, such as files, URLs, or other data sources. Resources have metadata including a URI, name, description, and content type.
- dup_content_type()¶
- Returns:
a newly allocated string containing the content type, or
Noneif not available- Return type:
Gets the content type for the resource.
New in version 1.1.
- dup_description()¶
- Returns:
a newly allocated string containing the description, or
Noneif not available- Return type:
Gets the description for the resource.
New in version 1.1.
- dup_name()¶
- Returns:
a newly allocated string containing the name, or
Noneif not available- Return type:
Gets the name for the resource.
New in version 1.1.
- dup_uri()¶
- Returns:
a newly allocated string containing the URI, or
Noneif not available- Return type:
Gets the URI for the resource.
New in version 1.1.
- emit_changed()¶
Emits the “changed” signal.
Subclasses should call this function when the resource’s properties or content have been modified to notify listeners of the change.
New in version 1.1.
- load_bytes()¶
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.Bytes], or rejects with error.
- Return type:
Loads the bytes for the resource.
This method asynchronously loads the resource content and returns a future that resolves to a [struct`GLib`.Bytes] containing the data.
New in version 1.1.
- load_json()¶
- Returns:
a [class`Dex`.Future] that resolves to a [struct`Json`.Node] or rejects with error.
- Return type:
If the content_type is “application/json” then the resource may implement this function to provide a
Json.Nodeinstead of a serialized byte buffer. This is helpful in situations where the protocol can pass structured information for JSON such as Model Context Protocol.New in version 1.1.
- do_dup_content_type() virtual¶
- Returns:
a newly allocated string containing the content type, or
Noneif not available- Return type:
Gets the content type for the resource.
New in version 1.1.
- do_dup_description() virtual¶
- Returns:
a newly allocated string containing the description, or
Noneif not available- Return type:
Gets the description for the resource.
New in version 1.1.
- do_dup_name() virtual¶
- Returns:
a newly allocated string containing the name, or
Noneif not available- Return type:
Gets the name for the resource.
New in version 1.1.
- do_dup_uri() virtual¶
- Returns:
a newly allocated string containing the URI, or
Noneif not available- Return type:
Gets the URI for the resource.
New in version 1.1.
- do_load_bytes() virtual¶
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.Bytes], or rejects with error.
- Return type:
Loads the bytes for the resource.
This method asynchronously loads the resource content and returns a future that resolves to a [struct`GLib`.Bytes] containing the data.
New in version 1.1.
- do_load_json() virtual¶
- Returns:
a [class`Dex`.Future] that resolves to a [struct`Json`.Node] or rejects with error.
- Return type:
If the content_type is “application/json” then the resource may implement this function to provide a
Json.Nodeinstead of a serialized byte buffer. This is helpful in situations where the protocol can pass structured information for JSON such as Model Context Protocol.New in version 1.1.
Signal Details¶
- Foundry.LlmResource.signals.changed(llm_resource)¶
- Signal Name:
changed- Flags:
- Parameters:
llm_resource (
Foundry.LlmResource) – The object which received the signal
Emitted when the resource has changed.
This signal is emitted when the resource’s properties or content have been modified. Subclasses should call [method`Foundry`.LlmResource.emit_changed] to emit this signal.
New in version 1.1.
Property Details¶
- Foundry.LlmResource.props.content_type¶
-
The content type of the resource.
This indicates the format of the resource data, such as “text/plain”, “application/json”, or “image/png”.
- Foundry.LlmResource.props.description¶
-
The description of the resource.
A human-readable description providing additional context about the resource and its contents.
- Foundry.LlmResource.props.name¶
-
The name of the resource.
A human-readable name for the resource, typically used for display purposes in the UI.