mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-27 10:20:32 +03:00
8af6d61e76
* reorganize import level * add __init__, reorganize import from __init__ * reorganize import level * reorganize import level * fix circular import error by keep the import deep as "from models.settings" * fix the relative import * restor unwanted staged files * add backend/venv and backend/.env to gitignore * clean importing
60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
from uuid import UUID
|
|
|
|
from auth import AuthBearer
|
|
from fastapi import APIRouter, Depends
|
|
from models.databases.supabase.prompts import (
|
|
CreatePromptProperties,
|
|
PromptUpdatableProperties,
|
|
)
|
|
from models import Prompt
|
|
from repository.prompt import (
|
|
create_prompt,
|
|
get_prompt_by_id,
|
|
get_public_prompts,
|
|
update_prompt_by_id,
|
|
)
|
|
|
|
prompt_router = APIRouter()
|
|
|
|
|
|
@prompt_router.get("/prompts", dependencies=[Depends(AuthBearer())], tags=["Prompt"])
|
|
async def get_prompts() -> list[Prompt]:
|
|
"""
|
|
Retrieve all public prompt
|
|
"""
|
|
|
|
return get_public_prompts()
|
|
|
|
|
|
@prompt_router.get(
|
|
"/prompts/{prompt_id}", dependencies=[Depends(AuthBearer())], tags=["Prompt"]
|
|
)
|
|
async def get_prompt(prompt_id: UUID) -> Prompt | None:
|
|
"""
|
|
Retrieve a prompt by its id
|
|
"""
|
|
|
|
return get_prompt_by_id(prompt_id)
|
|
|
|
|
|
@prompt_router.put(
|
|
"/prompts/{prompt_id}", dependencies=[Depends(AuthBearer())], tags=["Prompt"]
|
|
)
|
|
async def update_prompt(
|
|
prompt_id: UUID, prompt: PromptUpdatableProperties
|
|
) -> Prompt | None:
|
|
"""
|
|
Update a prompt by its id
|
|
"""
|
|
|
|
return update_prompt_by_id(prompt_id, prompt)
|
|
|
|
|
|
@prompt_router.post("/prompts", dependencies=[Depends(AuthBearer())], tags=["Prompt"])
|
|
async def create_prompt_route(prompt: CreatePromptProperties) -> Prompt | None:
|
|
"""
|
|
Create a prompt by its id
|
|
"""
|
|
|
|
return create_prompt(prompt)
|