Foundry.LlmResource

g Foundry.LlmResource Foundry.LlmResource GObject.Object GObject.Object GObject.Object->Foundry.LlmResource

Subclasses:

Foundry.JsonListLlmResource, Foundry.JsonLlmResource

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

dup_content_type ()

dup_description ()

dup_name ()

dup_uri ()

emit_changed ()

load_bytes ()

load_json ()

Virtual Methods

Inherited:

GObject.Object (7)

do_dup_content_type ()

do_dup_description ()

do_dup_name ()

do_dup_uri ()

do_load_bytes ()

do_load_json ()

Properties

Name

Type

Flags

Short Description

content-type

str

r

description

str

r

name

str

r

uri

str

r

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

Emitted when the resource has changed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Foundry.LlmResource(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Foundry.LlmResourceClass

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 None if not available

Return type:

str or None

Gets the content type for the resource.

New in version 1.1.

dup_description()
Returns:

a newly allocated string containing the description, or None if not available

Return type:

str or None

Gets the description for the resource.

New in version 1.1.

dup_name()
Returns:

a newly allocated string containing the name, or None if not available

Return type:

str or None

Gets the name for the resource.

New in version 1.1.

dup_uri()
Returns:

a newly allocated string containing the URI, or None if not available

Return type:

str or None

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:

Dex.Future

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:

Dex.Future

If the content_type is “application/json” then the resource may implement this function to provide a Json.Node instead 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 None if not available

Return type:

str or None

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 None if not available

Return type:

str or None

Gets the description for the resource.

New in version 1.1.

do_dup_name() virtual
Returns:

a newly allocated string containing the name, or None if not available

Return type:

str or None

Gets the name for the resource.

New in version 1.1.

do_dup_uri() virtual
Returns:

a newly allocated string containing the URI, or None if not available

Return type:

str or None

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:

Dex.Future

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:

Dex.Future

If the content_type is “application/json” then the resource may implement this function to provide a Json.Node instead 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:

RUN_LAST

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
Name:

content-type

Type:

str

Default Value:

None

Flags:

READABLE

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
Name:

description

Type:

str

Default Value:

None

Flags:

READABLE

The description of the resource.

A human-readable description providing additional context about the resource and its contents.

Foundry.LlmResource.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE

The name of the resource.

A human-readable name for the resource, typically used for display purposes in the UI.

Foundry.LlmResource.props.uri
Name:

uri

Type:

str

Default Value:

None

Flags:

READABLE

The URI of the resource.

This identifies the location or source of the resource, which may be a file path, URL, or other identifier depending on the resource type.