LLMClientFunctions Model

class smarter.apps.llm_client.models.LLMClientFunctions(*args, **kwargs)[source]

Bases: TimestampedModel

Represents the set of callable functions that are available to a LLMClient instance within the Smarter platform.

This model is used to define and manage the specific functions that an llm_client can access or invoke during its operation. Each record in this model links an llm_client to a named function, enabling fine-grained control over the llm_client’s capabilities. The available functions are defined by a fixed set of choices, such as “weather”, “news”, “prices”, and “math”.

By associating functions with llm_clients, the platform allows for extensible and customizable llm_client behavior, supporting use cases where different llm_clients require access to different sets of features or integrations. This model is essential for scenarios where llm_clients need to perform actions, retrieve information, or interact with external APIs in a controlled and auditable manner.

Model Relationships

  • Each LLMClientFunctions entry is linked to one LLMClient instance.

  • Each entry specifies a function name from a predefined set of choices.

Usage Example

# Assign a function to an llm_client
LLMClientFunctions.objects.create(llm_client=my_llm_client, name="weather")

# List all functions available to an llm_client
functions = LLMClientFunctions.objects.filter(llm_client=my_llm_client)

Notes

  • The set of available functions is controlled by the CHOICES class attribute.

  • This model is intended for internal use to manage and audit llm_client capabilities.

  • Uniqueness is not enforced, so an llm_client may have multiple entries for the same function if needed.

Parameters:
  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • name (Unknown) –

    Name

    The name of the function available to the LLMClient. Example: “weather”

Relationship fields:

Parameters:

llm_client (Unknown) –

Llm client (related name: llmclientfunctions)

The LLMClient instance associated with this function. Example: LLMClient(id=1, name=”my-llm_client”)

CHOICES = [('get_current_weather', 'get_current_weather'), ('date_calculator', 'date_calculator'), ('calculator', 'calculator')]

The set of available function names that can be assigned to a LLMClient.

See Also:

  • smarter.apps.prompt.functions.function_weather.get_current_weather()

  • smarter.apps.prompt.functions.function_date_calculator.date_calculator()

  • smarter.apps.prompt.functions.function_calculator.calculator()

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

classmethod choices_list()[source]
created_at

DateTimeField

Created at

Timestamp indicating when the model instance was created.

This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.

Type:

Type

classmethod functions(llm_client)[source]

Returns a list of function names associated with the given LLMClient.

Parameters:

llm_client (LLMClient) – The LLMClient instance to retrieve functions for.

Returns:

List of function names.

Return type:

List[str]

classmethod get_cached_objects(invalidate=False, llm_client=None)[source]

Retrieve a queryset of LLMClientFunctions instances associated with a LLMClient using caching.

Parameters:
  • invalidate (Optional[bool]) – Whether to invalidate the cache for this retrieval.

  • llm_client – The LLMClient instance for which to retrieve functions.

Return type:

QuerySet

get_name_display(*, field=<django.db.models.CharField: name>)

Shows the label of the name. See get_FOO_display() for more information.

id

BigAutoField

Primary key: ID

Type:

Type

llm_client

ForeignKey to LLMClient

Llm client (related name: llmclientfunctions)

The LLMClient instance associated with this function. Example: LLMClient(id=1, name=”my-llm_client”)

Type:

Type

llm_client_id

Internal field, use llm_client instead.

name

CharField

Name

Choices:

  • get_current_weather

  • date_calculator

  • calculator

The name of the function available to the LLMClient. Example: “weather”

Type:

Type

objects = <django.db.models.Manager object>
updated_at

DateTimeField

Updated at

Timestamp indicating when the model instance was last updated.

This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.

Type:

Type