Skip to content

Commit

Permalink
create django dc endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sand194 committed May 15, 2024
1 parent 92c31a5 commit c1ecabe
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Empty file added api/bot/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions api/bot/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.contrib import admin
from .models import Bot

admin.site.register(Bot)
6 changes: 6 additions & 0 deletions api/bot/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class BotConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "bot"
Empty file added api/bot/migrations/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions api/bot/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.db import models


class Bot(models.Model):
text = models.TextField[str, str]()
9 changes: 9 additions & 0 deletions api/bot/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from ninja import Schema


class BotIn(Schema):
text:str


class BotOut(Schema):
text: str
3 changes: 3 additions & 0 deletions api/bot/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
14 changes: 14 additions & 0 deletions api/bot/views.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit c1ecabe

Please sign in to comment.