LLMClientRequests Model

class smarter.apps.llm_client.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 llm_client, 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 llm_client, the request payload, session information, and aggregation status.

Purpose and Usage

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

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

  • Debugging and trouble shooting of llm_client 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 llm_client that handled it.

Notes

  • This model is intended for internal use to support auditing, analytics, and operational monitoring of llm_client 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 llm_client workflows.

Example Usage

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

# Retrieve all requests for a specific llm_client
requests = LLMClientRequests.objects.filter(llm_client=my_llm_client)

See Also:

  • smarter.apps.llm_client.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:

llm_client (Unknown) – Llm client (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

llm_client

ForeignKey to LLMClient

Llm client (related name: llmclientrequests)

Type:

Type

llm_client_id

Internal field, use llm_client 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