Skip to content

Commit

Permalink
Removes old solution
Browse files Browse the repository at this point in the history
  • Loading branch information
amandasavluchinske committed Jun 21, 2024
1 parent b4bcd01 commit 1b9390e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
4 changes: 0 additions & 4 deletions django_ai_assistant/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ class AIAssistantNotDefinedError(Exception):

class AIUserNotAllowedError(Exception):
pass


class AIAssistantPrimaryKeyTypeNotInListError(Exception):
pass
18 changes: 1 addition & 17 deletions django_ai_assistant/models.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
import json
import uuid
from typing import Any

from django.conf import settings
from django.db import models
from django.db.models import F, Index, Manager

from django_ai_assistant.exceptions import AIAssistantPrimaryKeyTypeNotInListError


def get_id_field():
if settings.AI_ASSISTANT_PRIMARY_KEY_FIELD == "auto":
return int
elif settings.AI_ASSISTANT_PRIMARY_KEY_FIELD == "uuid":
return models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
elif settings.AI_ASSISTANT_PRIMARY_KEY_FIELD == "string":
return models.CharField(primary_key=True, max_length=255)
else:
raise AIAssistantPrimaryKeyTypeNotInListError


class Thread(models.Model):
id: Any = get_id_field() # noqa: A003
messages: Manager["Message"]
name = models.CharField(max_length=255, blank=True)
created_by = models.ForeignKey(
Expand All @@ -47,9 +32,8 @@ def __repr__(self) -> str:


class Message(models.Model):
id: Any = get_id_field() # noqa: A003
thread = models.ForeignKey(Thread, on_delete=models.CASCADE, related_name="messages")
thread_id: int # noqa: A003 NEED TO LOOK AT THIS TOMORROW
thread_id: Any # noqa: A003
message = models.JSONField() # langchain BaseMessage
created_at = models.DateTimeField(auto_now_add=True)
# TODO: add created_by field
Expand Down
3 changes: 2 additions & 1 deletion example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"webpack_loader",
"django_ai_assistant",
# "django_ai_assistant",
"example.apps.AIAssistantConfigOverride",
"demo", # contains the views
"weather",
"movies",
Expand Down

0 comments on commit 1b9390e

Please sign in to comment.