Skip to content

Commit

Permalink
finalize uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Oct 3, 2024
1 parent c035f5b commit c87da79
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
15 changes: 15 additions & 0 deletions parley/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ def handle_uploaded_file(self, td, f, counts):
f"unknown type \"{row['type']}\" on line {r} of {f.name}"
)

# Handle Foreign Keys
if rtype == Prompt:
self.link_reference(row, 'evaluation', Evaluation)
elif rtype == Response:
self.link_reference(row, 'model', LLM)
self.link_reference(row, 'prompt', Prompt)

counts.increment(f.name, *rtype.objects.get_or_create(**row))

def read_jsonlines(self, path):
Expand All @@ -159,3 +166,11 @@ def write_temporary_file(self, td, f):
for chunk in f.chunks():
fh.write(chunk)
return path

def link_reference(self, row, key, model):
try:
row[key] = model.objects.get(id=row[key])
except (KeyError, model.DoesNotExist):
raise ParlanceUploadError(
f"could not associate \"{row.get(key, '')}\" with existing {model.__name__} object"
)
15 changes: 11 additions & 4 deletions parley/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.1 on 2024-10-03 12:00
# Generated by Django 5.1.1 on 2024-10-03 20:30

import django.db.models.deletion
import parley.validators
Expand Down Expand Up @@ -60,8 +60,9 @@ class Migration(migrations.Migration):
"description",
models.TextField(
blank=True,
default="",
default=None,
help_text="Any notes or other descriptive information about the evaluation",
null=True,
),
),
(
Expand Down Expand Up @@ -190,7 +191,10 @@ class Migration(migrations.Migration):
(
"trained_on",
models.DateTimeField(
help_text="The timestamp that the model started training"
blank=True,
default=None,
help_text="The timestamp that the model started training",
null=True,
),
),
(
Expand Down Expand Up @@ -396,7 +400,10 @@ class Migration(migrations.Migration):
(
"inference_on",
models.DateTimeField(
help_text="The timestamp that the LLM started the inferencing"
blank=True,
default=None,
help_text="The timestamp that the LLM started the inferencing",
null=True,
),
),
(
Expand Down
19 changes: 13 additions & 6 deletions parley/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class LLM(BaseModel):
)

trained_on = models.DateTimeField(
null=False, blank=False,
null=True, default=None, blank=True,
help_text="The timestamp that the model started training"
)

Expand All @@ -136,6 +136,9 @@ def training_completed(self):
return None
return self.trained_on + self.training_duration

def __str__(self):
return self.name


class Evaluation(BaseModel):
"""
Expand All @@ -162,14 +165,14 @@ class Evaluation(BaseModel):
)

description = models.TextField(
null=False,
null=True,
blank=True,
default="",
default=None,
help_text="Any notes or other descriptive information about the evaluation",
)

active = models.BooleanField(
default=True,
default=True, null=False,
help_text="This prompt set should be used in evaluations of new models",
)

Expand All @@ -180,6 +183,9 @@ class Meta:
verbose_name = "evaluation"
verbose_name_plural = "evaluations"

def __str__(self):
return self.name


class Prompt(BaseModel):
"""
Expand Down Expand Up @@ -316,8 +322,9 @@ class Response(BaseModel):
)

inference_on = models.DateTimeField(
null=False,
blank=False,
null=True,
blank=True,
default=None,
help_text="The timestamp that the LLM started the inferencing",
)

Expand Down

0 comments on commit c87da79

Please sign in to comment.