LLMClientRequests Model

class smarter.apps.llmclient.models.LLMClientRequests(*args, **kwargs)[source]

Bases: TimestampedModel

Stores the request history for a LLMClient instance within the Smarter platform.

This model is designed to record and manage all incoming requests made to an llmclient, providing a persistent audit trail of interactions for analysis, debugging, and reporting. Each record in this model captures the details of a single request, including the associated llmclient, the request payload, session information, and aggregation status.

Purpose and Usage

The LLMClientRequests model enables comprehensive tracking of llmclient usage and user interactions. By storing each request, the platform can support features such as:

  • Request analytics and reporting for llmclient performance and user engagement.

  • Debugging and trouble shooting of llmclient behavior by reviewing historical requests.

  • Session management, allowing grouping and correlation of requests within a user session.

  • Aggregation of requests for batch processing or summarization.

Model Relationships

  • Each LLMClientRequests entry is linked to one LLMClient instance, establishing a direct association between the request and the llmclient that handled it.

Notes

  • This model is intended for internal use to support auditing, analytics, and operational monitoring of llmclient activity.

  • The request data is stored in JSON format to accommodate flexible and extensible payload structures.

  • Aggregation support allows for efficient handling of bulk or grouped requests, which may be relevant for advanced llmclient workflows.

Example Usage

# Record a new request for an llmclient
LLMClientRequests.objects.create(
    llmclient=my_llmclient,
    request={"message": "Hello, llmclient!"},
    session_key="abc123",
    is_aggregation=False,
)

# Retrieve all requests for a specific llmclient
requests = LLMClientRequests.objects.filter(llmclient=my_llmclient)

See Also:

  • smarter.apps.llmclient.tasks

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • request (Unknown) – Request

  • session_key (Unknown) – Session key

  • is_aggregation (Unknown) – Is aggregation

Relationship fields:

Parameters:

llmclient (Unknown) – Llmclient (related name: llmclientrequests)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

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

id

BigAutoField

Primary key: ID

Type:

Type

is_aggregation

BooleanField

Is aggregation

Type:

Type

llmclient

ForeignKey to LLMClient

Llmclient (related name: llmclientrequests)

Type:

Type

llmclient_id

Internal field, use llmclient instead.

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

JSONField

Request

Type:

Type

session_key

CharField

Session key

Type:

Type

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