Skip to content

Commit

Permalink
Removed non null constraint for fields in token usage table (#374)
Browse files Browse the repository at this point in the history
Co-authored-by: vishnuszipstack <[email protected]>
  • Loading branch information
Deepak-Kesavan and vishnuszipstack authored Jun 2, 2024
1 parent 9f7e069 commit f41509b
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Generated by Django 4.2.1 on 2024-06-01 10:18

import uuid

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("usage", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="usage",
name="adapter_instance_id",
field=models.CharField(
db_comment="Identifier for the adapter instance", max_length=255
),
),
migrations.AlterField(
model_name="usage",
name="completion_tokens",
field=models.IntegerField(
db_comment="Number of tokens used for the completion"
),
),
migrations.AlterField(
model_name="usage",
name="embedding_tokens",
field=models.IntegerField(db_comment="Number of tokens used for embedding"),
),
migrations.AlterField(
model_name="usage",
name="execution_id",
field=models.CharField(
blank=True,
db_comment="Identifier for the execution instance",
max_length=255,
null=True,
),
),
migrations.AlterField(
model_name="usage",
name="id",
field=models.UUIDField(
db_comment="Primary key for the usage entry, automatically generated UUID",
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
migrations.AlterField(
model_name="usage",
name="model_name",
field=models.CharField(db_comment="Name of the model used", max_length=255),
),
migrations.AlterField(
model_name="usage",
name="prompt_tokens",
field=models.IntegerField(
db_comment="Number of tokens used for the prompt"
),
),
migrations.AlterField(
model_name="usage",
name="run_id",
field=models.CharField(
blank=True,
db_comment="Identifier for the run",
max_length=255,
null=True,
),
),
migrations.AlterField(
model_name="usage",
name="total_tokens",
field=models.IntegerField(db_comment="Total number of tokens used"),
),
migrations.AlterField(
model_name="usage",
name="usage_type",
field=models.CharField(db_comment="Type of usage", max_length=255),
),
migrations.AlterField(
model_name="usage",
name="workflow_id",
field=models.CharField(
blank=True,
db_comment="Identifier for the workflow",
max_length=255,
null=True,
),
),
]
44 changes: 33 additions & 11 deletions backend/usage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,39 @@


class Usage(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
workflow_id = models.CharField(max_length=255)
execution_id = models.CharField(max_length=255)
adapter_instance_id = models.CharField(max_length=255)
run_id = models.CharField(max_length=255)
usage_type = models.CharField(max_length=255)
model_name = models.CharField(max_length=255)
embedding_tokens = models.IntegerField()
prompt_tokens = models.IntegerField()
completion_tokens = models.IntegerField()
total_tokens = models.IntegerField()
id = models.UUIDField(
primary_key=True,
default=uuid.uuid4,
editable=False,
db_comment="Primary key for the usage entry, automatically generated UUID",
)
workflow_id = models.CharField(
max_length=255, null=True, blank=True, db_comment="Identifier for the workflow"
)
execution_id = models.CharField(
max_length=255,
null=True,
blank=True,
db_comment="Identifier for the execution instance",
)
adapter_instance_id = models.CharField(
max_length=255, db_comment="Identifier for the adapter instance"
)
run_id = models.CharField(
max_length=255, null=True, blank=True, db_comment="Identifier for the run"
)
usage_type = models.CharField(max_length=255, db_comment="Type of usage")
model_name = models.CharField(max_length=255, db_comment="Name of the model used")
embedding_tokens = models.IntegerField(
db_comment="Number of tokens used for embedding"
)
prompt_tokens = models.IntegerField(
db_comment="Number of tokens used for the prompt"
)
completion_tokens = models.IntegerField(
db_comment="Number of tokens used for the completion"
)
total_tokens = models.IntegerField(db_comment="Total number of tokens used")

def __str__(self):
return str(self.id)
Expand Down

0 comments on commit f41509b

Please sign in to comment.