fastapi-fullstack 0.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapi_fullstack-0.1.7.dist-info/METADATA +739 -0
- fastapi_fullstack-0.1.7.dist-info/RECORD +241 -0
- fastapi_fullstack-0.1.7.dist-info/WHEEL +4 -0
- fastapi_fullstack-0.1.7.dist-info/entry_points.txt +2 -0
- fastapi_fullstack-0.1.7.dist-info/licenses/LICENSE +21 -0
- fastapi_gen/__init__.py +3 -0
- fastapi_gen/cli.py +442 -0
- fastapi_gen/config.py +356 -0
- fastapi_gen/generator.py +207 -0
- fastapi_gen/prompts.py +874 -0
- fastapi_gen/template/VARIABLES.md +276 -0
- fastapi_gen/template/cookiecutter.json +93 -0
- fastapi_gen/template/hooks/post_gen_project.py +355 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.env.prod.example +56 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +150 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.gitignore +109 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/AGENTS.md +55 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/CLAUDE.md +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/Makefile +315 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/README.md +768 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.dockerignore +60 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.env.example +155 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.pre-commit-config.yaml +32 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/Dockerfile +56 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/env.py +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/script.py.mako +30 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/.gitkeep +0 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic.ini +48 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/__init__.py +3 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/admin.py +447 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/__init__.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/assistant.py +226 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/langchain_assistant.py +226 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/prompts.py +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/tools/__init__.py +13 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/tools/datetime_tool.py +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/deps.py +541 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/exception_handlers.py +98 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/router.py +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/__init__.py +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/__init__.py +87 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/agent.py +902 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/auth.py +395 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/conversations.py +498 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/health.py +227 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/items.py +275 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/oauth.py +205 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/sessions.py +168 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/users.py +333 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/webhooks.py +477 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/ws.py +46 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/versioning.py +221 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/clients/__init__.py +14 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/clients/redis.py +88 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/__init__.py +117 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/cleanup.py +75 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/example.py +28 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/seed.py +266 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/__init__.py +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/cache.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/config.py +267 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/csrf.py +153 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/exceptions.py +122 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/logfire_setup.py +101 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/middleware.py +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/oauth.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/rate_limit.py +58 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/sanitize.py +271 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/security.py +102 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/__init__.py +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/base.py +41 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/__init__.py +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/conversation.py +319 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/item.py +96 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/session.py +126 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/user.py +218 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/webhook.py +244 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/session.py +130 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/main.py +334 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/pipelines/__init__.py +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/pipelines/base.py +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/__init__.py +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/base.py +154 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/conversation.py +838 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/item.py +222 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/session.py +318 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/user.py +322 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/webhook.py +358 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/__init__.py +50 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/base.py +57 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/conversation.py +192 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/item.py +52 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/session.py +42 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/token.py +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/user.py +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/webhook.py +89 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/__init__.py +38 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/conversation.py +850 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/item.py +246 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/session.py +333 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user.py +432 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/webhook.py +561 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/__init__.py +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/celery_app.py +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/taskiq_app.py +38 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/__init__.py +25 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/examples.py +106 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/schedules.py +29 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/taskiq_examples.py +92 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/cli/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/cli/commands.py +438 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/pyproject.toml +180 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/scripts/.gitkeep +0 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_auth.py +242 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_exceptions.py +151 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_health.py +113 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_items.py +310 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_users.py +253 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/conftest.py +151 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_admin.py +890 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_agents.py +261 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_clients.py +183 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_commands.py +173 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_core.py +143 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_pipelines.py +118 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_repositories.py +181 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_security.py +124 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_services.py +363 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_worker.py +85 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.dev.yml +242 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.frontend.yml +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.prod.yml +435 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.yml +241 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/adding_features.md +132 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/architecture.md +63 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/patterns.md +161 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docs/testing.md +120 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.dockerignore +40 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.env.example +12 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.gitignore +45 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.prettierignore +19 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.prettierrc +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/Dockerfile +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/README.md +648 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/auth.setup.ts +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/auth.spec.ts +134 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/chat.spec.ts +207 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/home.spec.ts +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/instrumentation.ts +14 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/messages/en.json +84 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/messages/pl.json +84 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/next.config.ts +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/package.json +69 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/playwright.config.ts +101 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/postcss.config.mjs +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(auth)/layout.tsx +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(auth)/login/page.tsx +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(auth)/register/page.tsx +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/chat/page.tsx +48 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/dashboard/page.tsx +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/layout.tsx +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/(dashboard)/profile/page.tsx +152 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/auth/callback/page.tsx +113 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/layout.tsx +46 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/[locale]/page.tsx +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/login/route.ts +58 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/logout/route.ts +24 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/me/route.ts +39 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/oauth-callback/route.ts +50 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/refresh/route.ts +54 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/register/route.ts +26 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/[id]/messages/route.ts +41 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/[id]/route.ts +108 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/route.ts +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/health/route.ts +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/globals.css +323 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/layout.tsx +22 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/providers.tsx +29 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/index.ts +2 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/login-form.tsx +120 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/register-form.tsx +153 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-container.tsx +234 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-input.tsx +72 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/conversation-sidebar.tsx +328 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/copy-button.tsx +46 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/index.ts +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/local-conversation-sidebar.tsx +295 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/markdown-content.tsx +167 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-item.tsx +79 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-list.tsx +18 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/tool-call-card.tsx +79 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/icons/google-icon.tsx +32 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/icons/index.ts +3 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/language-switcher.tsx +97 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/header.tsx +65 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/index.ts +2 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/sidebar.tsx +82 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/index.ts +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/theme-provider.tsx +53 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/theme-toggle.tsx +105 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/badge.tsx +35 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/button.test.tsx +75 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/button.tsx +56 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/card.tsx +82 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/index.ts +13 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/input.tsx +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/label.tsx +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/sheet.tsx +109 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/index.ts +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-auth.ts +97 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-chat.ts +203 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-conversations.ts +181 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-local-chat.ts +165 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-websocket.ts +105 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/i18n.ts +37 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/api-client.ts +90 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/constants.ts +39 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/server-api.ts +78 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/utils.test.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/utils.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/middleware.ts +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/auth-store.test.ts +72 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/auth-store.ts +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/chat-sidebar-store.ts +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/chat-store.ts +65 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/conversation-store.ts +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/index.ts +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/local-chat-store.ts +255 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/sidebar-store.ts +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/theme-store.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/api.ts +27 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/auth.ts +52 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/chat.ts +83 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/conversation.ts +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/index.ts +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/tsconfig.json +28 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/vitest.config.ts +36 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/vitest.setup.ts +56 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Button } from "@/components/ui";
|
|
5
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetClose } from "@/components/ui";
|
|
6
|
+
import { cn } from "@/lib/utils";
|
|
7
|
+
import { useLocalChatStore, useChatSidebarStore } from "@/stores";
|
|
8
|
+
import type { LocalConversation } from "@/stores/local-chat-store";
|
|
9
|
+
import {
|
|
10
|
+
MessageSquarePlus,
|
|
11
|
+
MessageSquare,
|
|
12
|
+
Trash2,
|
|
13
|
+
MoreVertical,
|
|
14
|
+
Pencil,
|
|
15
|
+
ChevronLeft,
|
|
16
|
+
ChevronRight,
|
|
17
|
+
PanelLeftClose,
|
|
18
|
+
PanelLeft,
|
|
19
|
+
} from "lucide-react";
|
|
20
|
+
|
|
21
|
+
interface LocalConversationItemProps {
|
|
22
|
+
conversation: LocalConversation;
|
|
23
|
+
isActive: boolean;
|
|
24
|
+
onSelect: () => void;
|
|
25
|
+
onDelete: () => void;
|
|
26
|
+
onRename: (title: string) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function LocalConversationItem({
|
|
30
|
+
conversation,
|
|
31
|
+
isActive,
|
|
32
|
+
onSelect,
|
|
33
|
+
onDelete,
|
|
34
|
+
onRename,
|
|
35
|
+
}: LocalConversationItemProps) {
|
|
36
|
+
const [showMenu, setShowMenu] = useState(false);
|
|
37
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
38
|
+
const [editTitle, setEditTitle] = useState(conversation.title || "");
|
|
39
|
+
|
|
40
|
+
const handleRename = () => {
|
|
41
|
+
if (editTitle.trim()) {
|
|
42
|
+
onRename(editTitle.trim());
|
|
43
|
+
}
|
|
44
|
+
setIsEditing(false);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const displayTitle =
|
|
48
|
+
conversation.title ||
|
|
49
|
+
`Chat ${new Date(conversation.createdAt).toLocaleDateString()}`;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
className={cn(
|
|
54
|
+
"group relative flex items-center gap-2 rounded-lg px-3 py-3 text-sm transition-colors cursor-pointer min-h-[44px]",
|
|
55
|
+
isActive
|
|
56
|
+
? "bg-secondary text-secondary-foreground"
|
|
57
|
+
: "text-muted-foreground hover:bg-secondary/50 hover:text-secondary-foreground"
|
|
58
|
+
)}
|
|
59
|
+
onClick={onSelect}
|
|
60
|
+
>
|
|
61
|
+
<MessageSquare className="h-4 w-4 shrink-0" />
|
|
62
|
+
{isEditing ? (
|
|
63
|
+
<input
|
|
64
|
+
type="text"
|
|
65
|
+
value={editTitle}
|
|
66
|
+
onChange={(e) => setEditTitle(e.target.value)}
|
|
67
|
+
onBlur={handleRename}
|
|
68
|
+
onKeyDown={(e) => {
|
|
69
|
+
if (e.key === "Enter") handleRename();
|
|
70
|
+
if (e.key === "Escape") setIsEditing(false);
|
|
71
|
+
}}
|
|
72
|
+
className="flex-1 bg-transparent outline-none text-foreground"
|
|
73
|
+
autoFocus
|
|
74
|
+
onClick={(e) => e.stopPropagation()}
|
|
75
|
+
/>
|
|
76
|
+
) : (
|
|
77
|
+
<span className="flex-1 truncate">{displayTitle}</span>
|
|
78
|
+
)}
|
|
79
|
+
|
|
80
|
+
<div className="relative">
|
|
81
|
+
<Button
|
|
82
|
+
variant="ghost"
|
|
83
|
+
size="sm"
|
|
84
|
+
className={cn(
|
|
85
|
+
"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 touch:opacity-100",
|
|
86
|
+
showMenu && "opacity-100"
|
|
87
|
+
)}
|
|
88
|
+
onClick={(e) => {
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
setShowMenu(!showMenu);
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<MoreVertical className="h-4 w-4" />
|
|
94
|
+
</Button>
|
|
95
|
+
|
|
96
|
+
{showMenu && (
|
|
97
|
+
<>
|
|
98
|
+
<div
|
|
99
|
+
className="fixed inset-0 z-10"
|
|
100
|
+
onClick={() => setShowMenu(false)}
|
|
101
|
+
/>
|
|
102
|
+
<div className="absolute right-0 top-8 z-20 w-40 rounded-md border bg-popover shadow-lg">
|
|
103
|
+
<button
|
|
104
|
+
className="flex w-full items-center gap-2 px-3 py-3 text-sm hover:bg-secondary min-h-[44px]"
|
|
105
|
+
onClick={(e) => {
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
setIsEditing(true);
|
|
108
|
+
setShowMenu(false);
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
<Pencil className="h-4 w-4" />
|
|
112
|
+
Rename
|
|
113
|
+
</button>
|
|
114
|
+
<button
|
|
115
|
+
className="flex w-full items-center gap-2 px-3 py-3 text-sm text-destructive hover:bg-destructive/10 min-h-[44px]"
|
|
116
|
+
onClick={(e) => {
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
onDelete();
|
|
119
|
+
setShowMenu(false);
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<Trash2 className="h-4 w-4" />
|
|
123
|
+
Delete
|
|
124
|
+
</button>
|
|
125
|
+
</div>
|
|
126
|
+
</>
|
|
127
|
+
)}
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function ConversationList({ onNavigate }: { onNavigate?: () => void }) {
|
|
134
|
+
const {
|
|
135
|
+
conversations,
|
|
136
|
+
currentConversationId,
|
|
137
|
+
selectConversation,
|
|
138
|
+
deleteConversation,
|
|
139
|
+
renameConversation,
|
|
140
|
+
createConversation,
|
|
141
|
+
} = useLocalChatStore();
|
|
142
|
+
|
|
143
|
+
const handleSelect = (id: string) => {
|
|
144
|
+
selectConversation(id);
|
|
145
|
+
onNavigate?.();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const handleNewChat = () => {
|
|
149
|
+
createConversation();
|
|
150
|
+
onNavigate?.();
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<>
|
|
155
|
+
<div className="p-3">
|
|
156
|
+
<Button
|
|
157
|
+
variant="outline"
|
|
158
|
+
size="sm"
|
|
159
|
+
className="w-full justify-start gap-2 h-10"
|
|
160
|
+
onClick={handleNewChat}
|
|
161
|
+
>
|
|
162
|
+
<MessageSquarePlus className="h-4 w-4" />
|
|
163
|
+
New Chat
|
|
164
|
+
</Button>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<div className="flex-1 overflow-y-auto px-3 pb-3 scrollbar-thin">
|
|
168
|
+
{conversations.length === 0 ? (
|
|
169
|
+
<div className="flex flex-col items-center justify-center py-8 text-center text-sm text-muted-foreground">
|
|
170
|
+
<MessageSquare className="h-8 w-8 mb-2 opacity-50" />
|
|
171
|
+
<p>No conversations yet</p>
|
|
172
|
+
<p className="text-xs mt-1">Start a new chat to begin</p>
|
|
173
|
+
</div>
|
|
174
|
+
) : (
|
|
175
|
+
<div className="space-y-1">
|
|
176
|
+
{conversations.map((conversation) => (
|
|
177
|
+
<LocalConversationItem
|
|
178
|
+
key={conversation.id}
|
|
179
|
+
conversation={conversation}
|
|
180
|
+
isActive={conversation.id === currentConversationId}
|
|
181
|
+
onSelect={() => handleSelect(conversation.id)}
|
|
182
|
+
onDelete={() => deleteConversation(conversation.id)}
|
|
183
|
+
onRename={(title) => renameConversation(conversation.id, title)}
|
|
184
|
+
/>
|
|
185
|
+
))}
|
|
186
|
+
</div>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div className="border-t px-3 py-2">
|
|
191
|
+
<p className="text-xs text-muted-foreground text-center">
|
|
192
|
+
Stored in browser
|
|
193
|
+
</p>
|
|
194
|
+
</div>
|
|
195
|
+
</>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
interface LocalConversationSidebarProps {
|
|
200
|
+
className?: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function LocalConversationSidebar({
|
|
204
|
+
className,
|
|
205
|
+
}: LocalConversationSidebarProps) {
|
|
206
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
207
|
+
const { isOpen, close } = useChatSidebarStore();
|
|
208
|
+
|
|
209
|
+
if (isCollapsed) {
|
|
210
|
+
return (
|
|
211
|
+
<div
|
|
212
|
+
className={cn(
|
|
213
|
+
"hidden md:flex flex-col items-center border-r bg-background py-4 w-12",
|
|
214
|
+
className
|
|
215
|
+
)}
|
|
216
|
+
>
|
|
217
|
+
<Button
|
|
218
|
+
variant="ghost"
|
|
219
|
+
size="sm"
|
|
220
|
+
className="h-10 w-10 p-0 mb-4"
|
|
221
|
+
onClick={() => setIsCollapsed(false)}
|
|
222
|
+
>
|
|
223
|
+
<ChevronRight className="h-4 w-4" />
|
|
224
|
+
</Button>
|
|
225
|
+
<Button
|
|
226
|
+
variant="ghost"
|
|
227
|
+
size="sm"
|
|
228
|
+
className="h-10 w-10 p-0"
|
|
229
|
+
onClick={() => {
|
|
230
|
+
useLocalChatStore.getState().createConversation();
|
|
231
|
+
}}
|
|
232
|
+
title="New Chat"
|
|
233
|
+
>
|
|
234
|
+
<MessageSquarePlus className="h-4 w-4" />
|
|
235
|
+
</Button>
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<>
|
|
242
|
+
<aside
|
|
243
|
+
className={cn(
|
|
244
|
+
"hidden md:flex w-64 shrink-0 flex-col border-r bg-background",
|
|
245
|
+
className
|
|
246
|
+
)}
|
|
247
|
+
>
|
|
248
|
+
<div className="flex items-center justify-between border-b px-4 py-3 h-12">
|
|
249
|
+
<h2 className="font-semibold text-sm">Local Chats</h2>
|
|
250
|
+
<Button
|
|
251
|
+
variant="ghost"
|
|
252
|
+
size="sm"
|
|
253
|
+
className="h-8 w-8 p-0"
|
|
254
|
+
onClick={() => setIsCollapsed(true)}
|
|
255
|
+
>
|
|
256
|
+
<ChevronLeft className="h-4 w-4" />
|
|
257
|
+
</Button>
|
|
258
|
+
</div>
|
|
259
|
+
<ConversationList />
|
|
260
|
+
</aside>
|
|
261
|
+
|
|
262
|
+
<Sheet open={isOpen} onOpenChange={close}>
|
|
263
|
+
<SheetContent side="left" className="w-80 p-0">
|
|
264
|
+
<SheetHeader className="h-12 px-4">
|
|
265
|
+
<SheetTitle>Local Chats</SheetTitle>
|
|
266
|
+
<SheetClose onClick={close} />
|
|
267
|
+
</SheetHeader>
|
|
268
|
+
<div className="flex flex-col h-[calc(100%-48px)]">
|
|
269
|
+
<ConversationList onNavigate={close} />
|
|
270
|
+
</div>
|
|
271
|
+
</SheetContent>
|
|
272
|
+
</Sheet>
|
|
273
|
+
</>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function ChatSidebarToggle() {
|
|
278
|
+
const { toggle, isOpen } = useChatSidebarStore();
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<Button
|
|
282
|
+
variant="ghost"
|
|
283
|
+
size="sm"
|
|
284
|
+
className="h-10 w-10 p-0 md:hidden"
|
|
285
|
+
onClick={toggle}
|
|
286
|
+
>
|
|
287
|
+
{isOpen ? (
|
|
288
|
+
<PanelLeftClose className="h-5 w-5" />
|
|
289
|
+
) : (
|
|
290
|
+
<PanelLeft className="h-5 w-5" />
|
|
291
|
+
)}
|
|
292
|
+
<span className="sr-only">Toggle chat list</span>
|
|
293
|
+
</Button>
|
|
294
|
+
);
|
|
295
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/markdown-content.tsx
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import ReactMarkdown from "react-markdown";
|
|
4
|
+
import remarkGfm from "remark-gfm";
|
|
5
|
+
import rehypeHighlight from "rehype-highlight";
|
|
6
|
+
import { CopyButton } from "./copy-button";
|
|
7
|
+
|
|
8
|
+
interface MarkdownContentProps {
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function MarkdownContent({ content }: MarkdownContentProps) {
|
|
13
|
+
return (
|
|
14
|
+
<ReactMarkdown
|
|
15
|
+
remarkPlugins={[remarkGfm]}
|
|
16
|
+
rehypePlugins={[rehypeHighlight]}
|
|
17
|
+
components={% raw %}{{{% endraw %}
|
|
18
|
+
pre({ children, ...props }) {
|
|
19
|
+
const codeElement = children as React.ReactElement<{
|
|
20
|
+
children?: string;
|
|
21
|
+
}>;
|
|
22
|
+
const codeContent =
|
|
23
|
+
typeof codeElement?.props?.children === "string"
|
|
24
|
+
? codeElement.props.children
|
|
25
|
+
: "";
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="group relative">
|
|
29
|
+
<pre
|
|
30
|
+
className="overflow-x-auto rounded-lg bg-muted/50 p-3 text-xs"
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</pre>
|
|
35
|
+
{codeContent && (
|
|
36
|
+
<div className="absolute right-2 top-2">
|
|
37
|
+
<CopyButton text={codeContent} className="opacity-100" />
|
|
38
|
+
</div>
|
|
39
|
+
)}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
code({ className, children, ...props }) {
|
|
44
|
+
const isInline = !className;
|
|
45
|
+
if (isInline) {
|
|
46
|
+
return (
|
|
47
|
+
<code
|
|
48
|
+
className="rounded bg-muted px-1.5 py-0.5 text-xs font-mono"
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</code>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return (
|
|
56
|
+
<code className={className} {...props}>
|
|
57
|
+
{children}
|
|
58
|
+
</code>
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
a({ href, children, ...props }) {
|
|
62
|
+
return (
|
|
63
|
+
<a
|
|
64
|
+
href={href}
|
|
65
|
+
target="_blank"
|
|
66
|
+
rel="noopener noreferrer"
|
|
67
|
+
className="text-primary underline hover:text-primary/80"
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</a>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
p({ children, ...props }) {
|
|
75
|
+
return (
|
|
76
|
+
<p className="mb-2 last:mb-0" {...props}>
|
|
77
|
+
{children}
|
|
78
|
+
</p>
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
ul({ children, ...props }) {
|
|
82
|
+
return (
|
|
83
|
+
<ul className="mb-2 ml-4 list-disc last:mb-0" {...props}>
|
|
84
|
+
{children}
|
|
85
|
+
</ul>
|
|
86
|
+
);
|
|
87
|
+
},
|
|
88
|
+
ol({ children, ...props }) {
|
|
89
|
+
return (
|
|
90
|
+
<ol className="mb-2 ml-4 list-decimal last:mb-0" {...props}>
|
|
91
|
+
{children}
|
|
92
|
+
</ol>
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
li({ children, ...props }) {
|
|
96
|
+
return (
|
|
97
|
+
<li className="mb-1" {...props}>
|
|
98
|
+
{children}
|
|
99
|
+
</li>
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
h1({ children, ...props }) {
|
|
103
|
+
return (
|
|
104
|
+
<h1 className="mb-2 text-lg font-bold" {...props}>
|
|
105
|
+
{children}
|
|
106
|
+
</h1>
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
h2({ children, ...props }) {
|
|
110
|
+
return (
|
|
111
|
+
<h2 className="mb-2 text-base font-bold" {...props}>
|
|
112
|
+
{children}
|
|
113
|
+
</h2>
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
h3({ children, ...props }) {
|
|
117
|
+
return (
|
|
118
|
+
<h3 className="mb-2 text-sm font-bold" {...props}>
|
|
119
|
+
{children}
|
|
120
|
+
</h3>
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
blockquote({ children, ...props }) {
|
|
124
|
+
return (
|
|
125
|
+
<blockquote
|
|
126
|
+
className="mb-2 border-l-2 border-muted-foreground/50 pl-3 italic"
|
|
127
|
+
{...props}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</blockquote>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
table({ children, ...props }) {
|
|
134
|
+
return (
|
|
135
|
+
<div className="mb-2 overflow-x-auto">
|
|
136
|
+
<table className="min-w-full text-sm" {...props}>
|
|
137
|
+
{children}
|
|
138
|
+
</table>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
th({ children, ...props }) {
|
|
143
|
+
return (
|
|
144
|
+
<th
|
|
145
|
+
className="border-b border-muted px-2 py-1 text-left font-semibold"
|
|
146
|
+
{...props}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
</th>
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
td({ children, ...props }) {
|
|
153
|
+
return (
|
|
154
|
+
<td className="border-b border-muted/50 px-2 py-1" {...props}>
|
|
155
|
+
{children}
|
|
156
|
+
</td>
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
hr({ ...props }) {
|
|
160
|
+
return <hr className="my-3 border-muted" {...props} />;
|
|
161
|
+
},
|
|
162
|
+
{% raw %}}}{% endraw %}
|
|
163
|
+
>
|
|
164
|
+
{content}
|
|
165
|
+
</ReactMarkdown>
|
|
166
|
+
);
|
|
167
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-item.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
import type { ChatMessage } from "@/types";
|
|
5
|
+
import { ToolCallCard } from "./tool-call-card";
|
|
6
|
+
import { MarkdownContent } from "./markdown-content";
|
|
7
|
+
import { CopyButton } from "./copy-button";
|
|
8
|
+
import { User, Bot } from "lucide-react";
|
|
9
|
+
|
|
10
|
+
interface MessageItemProps {
|
|
11
|
+
message: ChatMessage;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function MessageItem({ message }: MessageItemProps) {
|
|
15
|
+
const isUser = message.role === "user";
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
className={cn(
|
|
20
|
+
"group flex gap-2 sm:gap-4 py-3 sm:py-4",
|
|
21
|
+
isUser && "flex-row-reverse"
|
|
22
|
+
)}
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
className={cn(
|
|
26
|
+
"flex-shrink-0 w-8 h-8 sm:w-9 sm:h-9 rounded-full flex items-center justify-center",
|
|
27
|
+
isUser ? "bg-primary text-primary-foreground" : "bg-orange-500/10 text-orange-500"
|
|
28
|
+
)}
|
|
29
|
+
>
|
|
30
|
+
{isUser ? <User className="h-4 w-4" /> : <Bot className="h-4 w-4 sm:h-5 sm:w-5" />}
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div className={cn(
|
|
34
|
+
"flex-1 space-y-2 overflow-hidden max-w-[88%] sm:max-w-[85%]",
|
|
35
|
+
isUser && "flex flex-col items-end"
|
|
36
|
+
)}>
|
|
37
|
+
{/* Only show message bubble if there's content or if it's streaming without tool calls */}
|
|
38
|
+
{(message.content || (message.isStreaming && (!message.toolCalls || message.toolCalls.length === 0))) && (
|
|
39
|
+
<div className={cn(
|
|
40
|
+
"relative rounded-2xl px-3 py-2 sm:px-4 sm:py-2.5",
|
|
41
|
+
isUser
|
|
42
|
+
? "bg-primary text-primary-foreground rounded-tr-sm"
|
|
43
|
+
: "bg-muted rounded-tl-sm"
|
|
44
|
+
)}>
|
|
45
|
+
{isUser ? (
|
|
46
|
+
<p className="whitespace-pre-wrap break-words text-sm">
|
|
47
|
+
{message.content}
|
|
48
|
+
</p>
|
|
49
|
+
) : (
|
|
50
|
+
<div className="text-sm prose-sm max-w-none">
|
|
51
|
+
<MarkdownContent content={message.content} />
|
|
52
|
+
{message.isStreaming && (
|
|
53
|
+
<span className="inline-block w-1.5 h-4 ml-1 bg-current animate-pulse rounded-full" />
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
{!isUser && message.content && !message.isStreaming && (
|
|
59
|
+
<div className="absolute -right-1 -top-1 sm:opacity-0 sm:group-hover:opacity-100">
|
|
60
|
+
<CopyButton
|
|
61
|
+
text={message.content}
|
|
62
|
+
className="bg-background/80 hover:bg-background shadow-sm"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{message.toolCalls && message.toolCalls.length > 0 && (
|
|
70
|
+
<div className="space-y-2 w-full">
|
|
71
|
+
{message.toolCalls.map((toolCall) => (
|
|
72
|
+
<ToolCallCard key={toolCall.id} toolCall={toolCall} />
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-list.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ChatMessage } from "@/types";
|
|
4
|
+
import { MessageItem } from "./message-item";
|
|
5
|
+
|
|
6
|
+
interface MessageListProps {
|
|
7
|
+
messages: ChatMessage[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function MessageList({ messages }: MessageListProps) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="space-y-4">
|
|
13
|
+
{messages.map((message) => (
|
|
14
|
+
<MessageItem key={message.id} message={message} />
|
|
15
|
+
))}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/tool-call-card.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui";
|
|
4
|
+
import type { ToolCall } from "@/types";
|
|
5
|
+
import { Wrench, CheckCircle, Loader2, AlertCircle } from "lucide-react";
|
|
6
|
+
import { cn } from "@/lib/utils";
|
|
7
|
+
import { CopyButton } from "./copy-button";
|
|
8
|
+
|
|
9
|
+
interface ToolCallCardProps {
|
|
10
|
+
toolCall: ToolCall;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ToolCallCard({ toolCall }: ToolCallCardProps) {
|
|
14
|
+
const statusConfig = {
|
|
15
|
+
pending: { icon: Loader2, color: "text-muted-foreground", animate: true },
|
|
16
|
+
running: { icon: Loader2, color: "text-blue-500", animate: true },
|
|
17
|
+
completed: { icon: CheckCircle, color: "text-green-500", animate: false },
|
|
18
|
+
error: { icon: AlertCircle, color: "text-red-500", animate: false },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { icon: StatusIcon, color, animate } = statusConfig[toolCall.status];
|
|
22
|
+
|
|
23
|
+
const argsText = JSON.stringify(toolCall.args, null, 2);
|
|
24
|
+
const resultText =
|
|
25
|
+
toolCall.result !== undefined
|
|
26
|
+
? typeof toolCall.result === "string"
|
|
27
|
+
? toolCall.result
|
|
28
|
+
: JSON.stringify(toolCall.result, null, 2)
|
|
29
|
+
: "";
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Card className="bg-muted/50">
|
|
33
|
+
<CardHeader className="py-2 px-3">
|
|
34
|
+
<div className="flex items-center justify-between">
|
|
35
|
+
<div className="flex items-center gap-2">
|
|
36
|
+
<Wrench className="h-4 w-4 text-muted-foreground" />
|
|
37
|
+
<CardTitle className="text-sm font-medium">
|
|
38
|
+
{toolCall.name}
|
|
39
|
+
</CardTitle>
|
|
40
|
+
</div>
|
|
41
|
+
<StatusIcon
|
|
42
|
+
className={cn("h-4 w-4", color, animate && "animate-spin")}
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
</CardHeader>
|
|
46
|
+
<CardContent className="py-2 px-3 space-y-2">
|
|
47
|
+
{/* Arguments */}
|
|
48
|
+
<div className="group relative">
|
|
49
|
+
<div className="flex items-center justify-between mb-1">
|
|
50
|
+
<p className="text-xs text-muted-foreground">Arguments:</p>
|
|
51
|
+
<CopyButton
|
|
52
|
+
text={argsText}
|
|
53
|
+
className="opacity-0 group-hover:opacity-100"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
<pre className="text-xs bg-background p-2 rounded overflow-x-auto">
|
|
57
|
+
{argsText}
|
|
58
|
+
</pre>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
{/* Result */}
|
|
62
|
+
{toolCall.result !== undefined && (
|
|
63
|
+
<div className="group relative">
|
|
64
|
+
<div className="flex items-center justify-between mb-1">
|
|
65
|
+
<p className="text-xs text-muted-foreground">Result:</p>
|
|
66
|
+
<CopyButton
|
|
67
|
+
text={resultText}
|
|
68
|
+
className="opacity-0 group-hover:opacity-100"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<pre className="text-xs bg-background p-2 rounded overflow-x-auto max-h-48 overflow-y-auto">
|
|
72
|
+
{resultText}
|
|
73
|
+
</pre>
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
</CardContent>
|
|
77
|
+
</Card>
|
|
78
|
+
);
|
|
79
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/icons/google-icon.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
2
|
+
import { SVGProps } from "react";
|
|
3
|
+
|
|
4
|
+
export function GoogleIcon(props: SVGProps<SVGSVGElement>) {
|
|
5
|
+
return (
|
|
6
|
+
<svg
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
{...props}
|
|
10
|
+
>
|
|
11
|
+
<path
|
|
12
|
+
fill="#4285F4"
|
|
13
|
+
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
14
|
+
/>
|
|
15
|
+
<path
|
|
16
|
+
fill="#34A853"
|
|
17
|
+
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
18
|
+
/>
|
|
19
|
+
<path
|
|
20
|
+
fill="#FBBC05"
|
|
21
|
+
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|
22
|
+
/>
|
|
23
|
+
<path
|
|
24
|
+
fill="#EA4335"
|
|
25
|
+
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
{%- else %}
|
|
31
|
+
// Google icon component - OAuth not enabled
|
|
32
|
+
{%- endif %}
|