From c1ecabe7846818f0c299fe9d41f5825ee1f1d870 Mon Sep 17 00:00:00 2001 From: sand194 <108941271+bbingo4@users.noreply.github.com> Date: Wed, 15 May 2024 16:58:55 +0200 Subject: [PATCH] create django dc endpoint --- api/api/api.py | 1 + api/bot/__init__.py | 0 api/bot/admin.py | 4 ++++ api/bot/apps.py | 6 ++++++ api/bot/migrations/__init__.py | 0 api/bot/models.py | 5 +++++ api/bot/schemas.py | 9 +++++++++ api/bot/tests.py | 3 +++ api/bot/views.py | 14 ++++++++++++++ 9 files changed, 42 insertions(+) create mode 100644 api/bot/__init__.py create mode 100644 api/bot/admin.py create mode 100644 api/bot/apps.py create mode 100644 api/bot/migrations/__init__.py create mode 100644 api/bot/models.py create mode 100644 api/bot/schemas.py create mode 100644 api/bot/tests.py create mode 100644 api/bot/views.py diff --git a/api/api/api.py b/api/api/api.py index 8ac62d8..c6c6c60 100644 --- a/api/api/api.py +++ b/api/api/api.py @@ -5,6 +5,7 @@ api.add_router("/", "documents.views.router") api.add_router("/", "chunks.views.router") +api.add_router("/", "bot.views.router") urlpatterns = [ path("api/", api.urls), diff --git a/api/bot/__init__.py b/api/bot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api/bot/admin.py b/api/bot/admin.py new file mode 100644 index 0000000..7263774 --- /dev/null +++ b/api/bot/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Bot + +admin.site.register(Bot) diff --git a/api/bot/apps.py b/api/bot/apps.py new file mode 100644 index 0000000..e089328 --- /dev/null +++ b/api/bot/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BotConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "bot" diff --git a/api/bot/migrations/__init__.py b/api/bot/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api/bot/models.py b/api/bot/models.py new file mode 100644 index 0000000..6dca41c --- /dev/null +++ b/api/bot/models.py @@ -0,0 +1,5 @@ +from django.db import models + + +class Bot(models.Model): + text = models.TextField[str, str]() diff --git a/api/bot/schemas.py b/api/bot/schemas.py new file mode 100644 index 0000000..1c96a20 --- /dev/null +++ b/api/bot/schemas.py @@ -0,0 +1,9 @@ +from ninja import Schema + + +class BotIn(Schema): + text:str + + +class BotOut(Schema): + text: str diff --git a/api/bot/tests.py b/api/bot/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/api/bot/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/api/bot/views.py b/api/bot/views.py new file mode 100644 index 0000000..c3d5f7f --- /dev/null +++ b/api/bot/views.py @@ -0,0 +1,14 @@ +from http import HTTPStatus +from dnajgo.http import HttpRequest + +from bot.schemas import BotIn, BotOut +from bot.models import Bot + +from ninja import Router + +router = Router(tags=["Bot"]) + + +@router.post("/bot/", response={HTTPStatus.CREATED: BotOut}) +def query_llm(request: HttpRequest, payload: BotIn): + return query_llm_controller(payload)