Skip to content

Commit

Permalink
Merge pull request #5 from AI4Bharat/new-models
Browse files Browse the repository at this point in the history
instructions and interactions models
  • Loading branch information
KunalTiwary authored Dec 27, 2023
2 parents ce68ffe + efdb04e commit ea4ffc8
Show file tree
Hide file tree
Showing 3 changed files with 385 additions and 0 deletions.
211 changes: 211 additions & 0 deletions backend/dataset/migrations/0044_instructions_interactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# Generated by Django 3.2.14 on 2023-12-27 10:55

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("dataset", "0043_auto_20230619_0811"),
]

operations = [
migrations.CreateModel(
name="Instructions",
fields=[
(
"datasetbase_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="dataset.datasetbase",
),
),
(
"meta_info_model",
models.CharField(
blank=True,
help_text="Model information for the instruction",
max_length=255,
null=True,
verbose_name="Meta Info Model",
),
),
(
"meta_info_auto_generated",
models.BooleanField(
blank=True,
help_text="Whether the instruction has been auto-generated",
null=True,
verbose_name="Meta Info Auto Generated",
),
),
(
"meta_info_intent",
models.CharField(
blank=True,
help_text="Intent information for the instruction",
max_length=255,
null=True,
verbose_name="Meta Info Intent",
),
),
(
"meta_info_domain",
models.CharField(
blank=True,
help_text="Domain information for the instruction",
max_length=255,
null=True,
verbose_name="Meta Info Domain",
),
),
(
"meta_info_structure",
models.CharField(
blank=True,
help_text="Structure information for the instruction",
max_length=255,
null=True,
verbose_name="Meta Info Structure",
),
),
(
"meta_info_language",
models.CharField(
blank=True,
choices=[
("English", "English"),
("Assamese", "Assamese"),
("Bengali", "Bengali"),
("Bodo", "Bodo"),
("Dogri", "Dogri"),
("Gujarati", "Gujarati"),
("Hindi", "Hindi"),
("Kannada", "Kannada"),
("Kashmiri", "Kashmiri"),
("Konkani", "Konkani"),
("Maithili", "Maithili"),
("Malayalam", "Malayalam"),
("Manipuri", "Manipuri"),
("Marathi", "Marathi"),
("Nepali", "Nepali"),
("Odia", "Odia"),
("Punjabi", "Punjabi"),
("Sanskrit", "Sanskrit"),
("Santali", "Santali"),
("Sindhi", "Sindhi"),
("Sinhala", "Sinhala"),
("Tamil", "Tamil"),
("Telugu", "Telugu"),
("Urdu", "Urdu"),
],
help_text="Language of the instruction",
max_length=20,
null=True,
verbose_name="Meta Info Language",
),
),
("instruction", models.TextField(verbose_name="Instruction")),
("examples", models.TextField(verbose_name="Examples")),
("hint", models.TextField(verbose_name="Hint")),
],
bases=("dataset.datasetbase",),
),
migrations.CreateModel(
name="Interactions",
fields=[
(
"datasetbase_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="dataset.datasetbase",
),
),
(
"interactions_json",
models.JSONField(verbose_name="Interactions JSON"),
),
(
"no_of_turns",
models.IntegerField(
help_text="Number of turns in the interaction",
verbose_name="Number of Turns",
),
),
(
"language",
models.CharField(
choices=[
("English", "English"),
("Assamese", "Assamese"),
("Bengali", "Bengali"),
("Bodo", "Bodo"),
("Dogri", "Dogri"),
("Gujarati", "Gujarati"),
("Hindi", "Hindi"),
("Kannada", "Kannada"),
("Kashmiri", "Kashmiri"),
("Konkani", "Konkani"),
("Maithili", "Maithili"),
("Malayalam", "Malayalam"),
("Manipuri", "Manipuri"),
("Marathi", "Marathi"),
("Nepali", "Nepali"),
("Odia", "Odia"),
("Punjabi", "Punjabi"),
("Sanskrit", "Sanskrit"),
("Santali", "Santali"),
("Sindhi", "Sindhi"),
("Sinhala", "Sinhala"),
("Tamil", "Tamil"),
("Telugu", "Telugu"),
("Urdu", "Urdu"),
],
help_text="Language of the interaction",
max_length=20,
verbose_name="Language",
),
),
(
"model",
models.CharField(
help_text="Model used for the interaction",
max_length=255,
verbose_name="Model",
),
),
(
"datetime",
models.DateTimeField(
help_text="Timestamp of the interaction",
verbose_name="Datetime",
),
),
(
"time_taken",
models.FloatField(
help_text="Time taken for the interaction",
verbose_name="Time Taken",
),
),
(
"instruction_id",
models.ForeignKey(
help_text="ID of the related instruction",
on_delete=django.db.models.deletion.CASCADE,
to="dataset.instructions",
verbose_name="Instruction ID",
),
),
],
bases=("dataset.datasetbase",),
),
]
117 changes: 117 additions & 0 deletions backend/dataset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,33 @@
"projects.tasks.export_project_in_place",
]

LANGUAGE_CHOICES = [
("English", "English"),
("Assamese", "Assamese"),
("Bengali", "Bengali"),
("Bodo", "Bodo"),
("Dogri", "Dogri"),
("Gujarati", "Gujarati"),
("Hindi", "Hindi"),
("Kannada", "Kannada"),
("Kashmiri", "Kashmiri"),
("Konkani", "Konkani"),
("Maithili", "Maithili"),
("Malayalam", "Malayalam"),
("Manipuri", "Manipuri"),
("Marathi", "Marathi"),
("Nepali", "Nepali"),
("Odia", "Odia"),
("Punjabi", "Punjabi"),
("Sanskrit", "Sanskrit"),
("Santali", "Santali"),
("Sindhi", "Sindhi"),
("Sinhala", "Sinhala"),
("Tamil", "Tamil"),
("Telugu", "Telugu"),
("Urdu", "Urdu"),
]


class DatasetInstance(models.Model):
"""
Expand Down Expand Up @@ -607,3 +634,93 @@ def __str__(self):
# sentence = models.TextField()
# gloss_sequence = models.TextField()
# duration = models.TimeField()


class Instructions(DatasetBase):
"""
Subclass model for Instructions
"""

meta_info_model = models.CharField(
max_length=255,
verbose_name="Meta Info Model",
null=True,
blank=True,
help_text="Model information for the instruction",
)
meta_info_auto_generated = models.BooleanField(
verbose_name="Meta Info Auto Generated",
null=True,
blank=True,
help_text="Whether the instruction has been auto-generated",
)
meta_info_intent = models.CharField(
max_length=255,
verbose_name="Meta Info Intent",
null=True,
blank=True,
help_text="Intent information for the instruction",
)
meta_info_domain = models.CharField(
max_length=255,
verbose_name="Meta Info Domain",
null=True,
blank=True,
help_text="Domain information for the instruction",
)
meta_info_structure = models.CharField(
max_length=255,
verbose_name="Meta Info Structure",
null=True,
blank=True,
help_text="Structure information for the instruction",
)
meta_info_language = models.CharField(
max_length=20,
choices=LANGUAGE_CHOICES,
verbose_name="Meta Info Language",
null=True,
blank=True,
help_text="Language of the instruction",
)
instruction = models.TextField(verbose_name="Instruction")
examples = models.TextField(verbose_name="Examples")
hint = models.TextField(verbose_name="Hint")

def __str__(self):
return f"{self.id} - {self.instruction}"


class Interactions(DatasetBase):
"""
Subclass model for Interactions
"""

instruction_id = models.ForeignKey(
Instructions,
on_delete=models.CASCADE,
verbose_name="Instruction ID",
help_text="ID of the related instruction",
)
interactions_json = models.JSONField(verbose_name="Interactions JSON")
no_of_turns = models.IntegerField(
verbose_name="Number of Turns", help_text="Number of turns in the interaction"
)
language = models.CharField(
max_length=20,
choices=LANGUAGE_CHOICES,
verbose_name="Language",
help_text="Language of the interaction",
)
model = models.CharField(
max_length=255, verbose_name="Model", help_text="Model used for the interaction"
)
datetime = models.DateTimeField(
verbose_name="Datetime", help_text="Timestamp of the interaction"
)
time_taken = models.FloatField(
verbose_name="Time Taken", help_text="Time taken for the interaction"
)

def __str__(self):
return f"{self.id} - Interaction with Instruction {self.instruction_id_id}"
57 changes: 57 additions & 0 deletions backend/users/migrations/0031_auto_20231227_1055.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Generated by Django 3.2.14 on 2023-12-27 10:55

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("users", "0030_alter_user_profile_photo"),
]

operations = [
migrations.AddField(
model_name="user",
name="address",
field=models.TextField(blank=True, verbose_name="address"),
),
migrations.AddField(
model_name="user",
name="city",
field=models.CharField(blank=True, max_length=255, verbose_name="city"),
),
migrations.AddField(
model_name="user",
name="date_of_birth",
field=models.DateField(blank=True, null=True, verbose_name="date_of_birth"),
),
migrations.AddField(
model_name="user",
name="gender",
field=models.CharField(
blank=True,
choices=[("M", "Male"), ("F", "Female"), ("O", "Other")],
max_length=1,
verbose_name="gender",
),
),
migrations.AddField(
model_name="user",
name="guest_user",
field=models.BooleanField(
choices=[(True, "Yes"), (False, "No")],
default=False,
help_text="Indicates whether the user is a guest user.",
verbose_name="guest_user",
),
),
migrations.AddField(
model_name="user",
name="pin_code",
field=models.CharField(blank=True, max_length=10, verbose_name="Pin Code"),
),
migrations.AddField(
model_name="user",
name="state",
field=models.CharField(blank=True, max_length=255, verbose_name="state"),
),
]

0 comments on commit ea4ffc8

Please sign in to comment.