LLMClientFunctions Model
- class smarter.apps.llmclient.models.LLMClientFunctions(*args, **kwargs)[source]
Bases:
TimestampedModelRepresents 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 llmclient can access or invoke during its operation. Each record in this model links an llmclient to a named function, enabling fine-grained control over the llmclient’s capabilities. The available functions are defined by a fixed set of choices, such as “weather”, “news”, “prices”, and “math”.
By associating functions with llmclients, the platform allows for extensible and customizable llmclient behavior, supporting use cases where different llmclients require access to different sets of features or integrations. This model is essential for scenarios where llmclients 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
LLMClientinstance.Each entry specifies a function name from a predefined set of choices.
Usage Example
# Assign a function to an llmclient LLMClientFunctions.objects.create(llmclient=my_llmclient, name="weather") # List all functions available to an llmclient functions = LLMClientFunctions.objects.filter(llmclient=my_llmclient)
Notes
The set of available functions is controlled by the
CHOICESclass attribute.This model is intended for internal use to manage and audit llmclient capabilities.
Uniqueness is not enforced, so an llmclient 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:
llmclient (Unknown) –
Llmclient (related name:
llmclientfunctions)The LLMClient instance associated with this function. Example: LLMClient(id=1, name=”my-llmclient”)
- 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
- created_at
-
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(llmclient)[source]
Returns a list of function names associated with the given LLMClient.
- classmethod get_cached_objects(invalidate=False, llmclient=None)[source]
Retrieve a queryset of LLMClientFunctions instances associated with a LLMClient using caching.
- get_name_display(*, field=<django.db.models.CharField: name>)
Shows the label of the
name. Seeget_FOO_display()for more information.
- id
-
Primary key: ID
- Type:
Type
- llmclient
-
Llmclient (related name:
llmclientfunctions)The LLMClient instance associated with this function. Example: LLMClient(id=1, name=”my-llmclient”)
- Type:
Type
- name
-
Name
Choices:
get_current_weatherdate_calculatorcalculator
The name of the function available to the LLMClient. Example: “weather”
- Type:
Type
- objects = <django.db.models.Manager object>
- updated_at
-
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