From f15e43e63a0b5b2a2587f8c32b67cb23348b1c17 Mon Sep 17 00:00:00 2001 From: Steve Gao Date: Tue, 10 Jun 2025 18:32:26 -0700 Subject: [PATCH] remove bad mock --- ai_course_bot/.gitignore | 1 - ai_course_bot/ai-chatbot/.env.example | 24 - ai_course_bot/ai-chatbot/.eslintrc.json | 26 - ai_course_bot/ai-chatbot/.gitignore | 38 - ai_course_bot/ai-chatbot/Dockerfile | 24 - ai_course_bot/ai-chatbot/LICENSE | 13 - ai_course_bot/ai-chatbot/README.md | 71 - .../app/api/auth/[...nextauth]/route.ts | 2 - .../ai-chatbot/app/api/chat/route.ts | 58 - .../ai-chatbot/app/api/chat/save/route.ts | 11 - .../ai-chatbot/app/chat/[id]/page.tsx | 47 - .../components/button-scroll-to-bottom.tsx | 34 - .../app/core/components/chat-history.tsx | 45 - .../app/core/components/chat-list.tsx | 27 - .../core/components/chat-message-actions.tsx | 40 - .../app/core/components/chat-message.tsx | 85 - .../app/core/components/chat-panel.tsx | 110 - .../core/components/chat-scroll-anchor.tsx | 29 - .../app/core/components/chat-share-dialog.tsx | 106 - .../ai-chatbot/app/core/components/chat.tsx | 132 - .../app/core/components/clear-history.tsx | 80 - .../app/core/components/empty-screen.tsx | 61 - .../app/core/components/external-link.tsx | 29 - .../ai-chatbot/app/core/components/footer.tsx | 20 - .../ai-chatbot/app/core/components/header.tsx | 53 - .../app/core/components/login-button.tsx | 42 - .../app/core/components/markdown.tsx | 9 - .../app/core/components/prompt-form.tsx | 97 - .../app/core/components/providers.tsx | 20 - .../app/core/components/select-course.tsx | 54 - .../app/core/components/sidebar-actions.tsx | 128 - .../app/core/components/sidebar-desktop.tsx | 19 - .../app/core/components/sidebar-footer.tsx | 16 - .../app/core/components/sidebar-item.tsx | 124 - .../app/core/components/sidebar-items.tsx | 42 - .../app/core/components/sidebar-list.tsx | 64 - .../app/core/components/sidebar-mobile.tsx | 28 - .../app/core/components/sidebar-toggle.tsx | 24 - .../app/core/components/sidebar.tsx | 21 - .../core/components/tailwind-indicator.tsx | 14 - .../app/core/components/theme-toggle.tsx | 31 - .../app/core/components/ui/alert-dialog.tsx | 141 - .../app/core/components/ui/badge.tsx | 36 - .../app/core/components/ui/button.tsx | 57 - .../app/core/components/ui/codeblock.tsx | 148 - .../app/core/components/ui/dialog.tsx | 122 - .../app/core/components/ui/dropdown-menu.tsx | 128 - .../app/core/components/ui/icons.tsx | 652 -- .../app/core/components/ui/input.tsx | 25 - .../app/core/components/ui/label.tsx | 26 - .../app/core/components/ui/select.tsx | 123 - .../app/core/components/ui/separator.tsx | 31 - .../app/core/components/ui/sheet.tsx | 140 - .../app/core/components/ui/switch.tsx | 29 - .../app/core/components/ui/textarea.tsx | 24 - .../app/core/components/ui/tooltip.tsx | 30 - .../app/core/components/user-menu.tsx | 68 - .../app/core/lib/hooks/use-at-bottom.tsx | 23 - .../core/lib/hooks/use-copy-to-clipboard.tsx | 33 - .../app/core/lib/hooks/use-enter-submit.tsx | 23 - .../app/core/lib/hooks/use-local-storage.ts | 24 - .../app/core/lib/hooks/use-sidebar.tsx | 60 - .../ai-chatbot/app/core/lib/mongodb.ts | 29 - .../ai-chatbot/app/core/lib/types.ts | 20 - .../ai-chatbot/app/core/lib/utils.ts | 55 - .../ai-chatbot/app/core/utils/actions.ts | 149 - .../ai-chatbot/app/core/utils/auth.ts | 48 - .../ai-chatbot/app/core/utils/eventEmitter.ts | 5 - .../ai-chatbot/app/core/utils/middleware.ts | 5 - ai_course_bot/ai-chatbot/app/globals.css | 78 - ai_course_bot/ai-chatbot/app/layout.tsx | 72 - ai_course_bot/ai-chatbot/app/page.tsx | 8 - .../ai-chatbot/app/share/[id]/page.tsx | 50 - ai_course_bot/ai-chatbot/app/sign-in/page.tsx | 21 - ai_course_bot/ai-chatbot/docker-compose.yml | 8 - ai_course_bot/ai-chatbot/next-env.d.ts | 5 - ai_course_bot/ai-chatbot/next.config.js | 19 - ai_course_bot/ai-chatbot/package-lock.json | 9008 ----------------- ai_course_bot/ai-chatbot/package.json | 72 - ai_course_bot/ai-chatbot/pnpm-lock.yaml | 6373 ------------ ai_course_bot/ai-chatbot/postcss.config.js | 6 - ai_course_bot/ai-chatbot/prettier.config.cjs | 34 - ai_course_bot/ai-chatbot/public/TAI_logo.png | Bin 15724 -> 0 bytes .../ai-chatbot/public/TAI_prompt.png | Bin 12807 -> 0 bytes .../ai-chatbot/public/TAI_prompt_circular.png | Bin 542284 -> 0 bytes .../ai-chatbot/public/apple-touch-icon.png | Bin 10423 -> 0 bytes .../ai-chatbot/public/favicon-16x16.png | Bin 539 -> 0 bytes ai_course_bot/ai-chatbot/public/favicon.ico | Bin 15406 -> 0 bytes ai_course_bot/ai-chatbot/public/next.svg | 1 - .../ai-chatbot/public/tai_prompt_small.png | Bin 4928 -> 0 bytes ai_course_bot/ai-chatbot/public/thirteen.svg | 1 - ai_course_bot/ai-chatbot/public/vercel.svg | 1 - ai_course_bot/ai-chatbot/tailwind.config.js | 95 - ai_course_bot/ai-chatbot/tsconfig.json | 46 - .../ai-chatbot/update_and_restart.sh | 13 - ai_course_bot/scripts/build_fe_docker.sh | 2 - ai_course_bot/scripts/run_fe_docker.sh | 1 - .../.env.example | 0 .../ai_chatbot_backend => backend}/.gitignore | 0 .../ai_chatbot_backend => backend}/README.md | 0 .../__init__.py | 0 .../app/__init__.py | 0 .../app/admin/README.md | 0 .../app/admin/__init__.py | 0 .../app/admin/admin.py | 0 .../app/api/__init__.py | 0 .../app/api/deps.py | 0 .../app/api/v1/__init__.py | 0 .../app/api/v1/endpoints/__init__.py | 0 .../app/api/v1/endpoints/completions.py | 0 .../app/api/v1/endpoints/course_admin.py | 0 .../app/api/v1/endpoints/courses.py | 0 .../app/api/v1/endpoints/file_completions.py | 0 .../app/api/v1/endpoints/file_tester.py | 0 .../app/api/v1/endpoints/local_files.py | 0 .../app/api/v1/models/files.py | 0 .../app/api/v1/router.py | 0 .../app/api/v1/schemas/__init__.py | 0 .../app/api/v1/schemas/completion.py | 0 .../app/api/v1/schemas/course.py | 0 .../app/api/v1/schemas/course_admin.py | 0 .../app/api/v1/schemas/file_completion.py | 0 .../app/api/v1/schemas/files.py | 0 .../app/api/v1/services/__init__.py | 0 .../api/v1/services/completions_service.py | 0 .../api/v1/services/course_admin_service.py | 0 .../app/api/v1/services/courses_service.py | 0 .../app/api/v1/services/rag_retriever.py | 0 .../app/api/v1/services/rag_selector.py | 0 .../app/api/v1/utils/__init__.py | 0 .../app/api/v1/utils/stream_processing.py | 0 .../app/config.py | 0 .../app/core/__init__.py | 0 .../app/core/actions/__init__.py | 0 .../app/core/actions/llama_selector.py | 0 .../app/core/actions/llama_seletor.py | 0 .../app/core/actions/model_selector.py | 0 .../app/core/actions/openai_selector.py | 0 .../app/core/data/__init__.py | 0 .../core/data/fake_chat_completion_data.py | 0 .../app/core/database.py | 0 .../app/core/models/__init__.py | 0 .../app/core/models/chat_completion.py | 0 .../app/core/models/courses.py | 0 .../app/core/security.py | 0 .../app/dependencies/__init__.py | 0 .../app/dependencies/model.py | 0 .../app/dependencies/remote_model.py | 0 .../app/services/file_service.py | 0 .../app/v1/__init__.py | 0 .../app/v1/openai_mock.py | 0 .../documents/code_script/example_code.py | 0 .../CS61A/documents/exams/midterm_sample.pdf | Bin .../lab_material/01_Getting_Started_Guide.txt | 0 .../CS61A/videos/02_Lab_Instructions.mp4.stub | 0 .../code_script/test_61_code_script.py | 0 .../docs/FILES_API.md | 0 .../docs/README.md | 0 .../docs/api_streaming_reference_guide.md | 0 .../docs/authentication.md | 0 .../embeddings.db | Bin .../embeddiongs.db | 0 .../example_cc.txt | 0 .../example_ros_questions.txt | 0 .../ai_chatbot_backend => backend}/main.py | 0 .../postman/README.md | 0 .../postman/examples/completion/README.md | 0 .../examples/completion/cs61a_request.json | 0 .../examples/completion/non_rag_request.json | 0 .../examples/completion/rag_request.json | 0 .../completion/streaming_request.json | 0 .../postman/files_api_collection.json | 0 .../ai_chatbot_backend => backend}/pytest.ini | 0 .../requirements.txt | 0 .../scripts/generate_fixtures.py | 0 .../scripts/generate_postman_collection.py | 0 .../scripts/initialize_storage.py | 0 .../scripts/migrate_to_modern_files.py | 0 .../static/css/file_tester.css | 0 .../static/html/file_tester.html | 0 .../static/js/file_tester.js | 0 .../templates/file_tester.html | 0 .../ai_chatbot_backend => backend}/test.py | 0 .../test_auth.py | 0 .../tests/README.md | 0 .../tests/__init__.py | 0 .../tests/common/__init__.py | 0 .../common/test_base_classes/__init__.py | 0 .../test_base_classes/course_admin_base.py | 0 .../tests/common/test_utils/__init__.py | 0 .../test_utils/openai_format_validation.py | 0 .../tests/conftest.py | 0 .../tests/data/embeddings/Berkeley.pkl | Bin .../tests/data/embeddings/backup/Berkeley.pkl | Bin .../embeddings/pkl_test_file_generator.py | 0 .../tests/fixtures/README.md | 0 .../requests/cs61a_rag_request.json | 0 .../requests/cs61a_streaming_rag_request.json | 0 .../completions/requests/non_rag_request.json | 0 .../completions/requests/rag_request.json | 0 .../requests/streaming_non_rag_request.json | 0 .../requests/streaming_rag_request.json | 0 .../cs61a_non_streaming_rag_response.json | 0 .../cs61a_streaming_rag_response.json | 0 .../non_streaming_non_rag_response.json | 0 .../responses/non_streaming_rag_response.json | 0 .../responses/streaming_non_rag_response.json | 0 .../responses/streaming_rag_response.json | 0 .../requests/get_file_hierarchy_request.json | 0 ...get_file_hierarchy_with_depth_request.json | 0 .../requests/get_file_request.json | 0 .../requests/list_files_request.json | 0 .../get_file_hierarchy_response.json | 0 ...et_file_hierarchy_with_depth_response.json | 0 .../responses/list_files_response.json | 0 .../tests/integration_tests/__init__.py | 0 .../integration_tests/test_api/__init__.py | 0 .../test_api/test_course_admin_endpoints.py | 0 .../tests/test_fixtures.py | 0 .../tests/unit_tests/__init__.py | 0 .../tests/unit_tests/conftest.py | 0 .../unit_tests/test_admin_panel/__init__.py | 0 .../test_course_admin_panel.py | 0 .../tests/unit_tests/test_api/__init__.py | 0 .../unit_tests/test_api/test_v1/__init__.py | 0 .../test_v1/test_endpoints/__init__.py | 0 .../test_endpoints/test_completions.py | 0 .../test_v1/test_endpoints/test_courses.py | 0 .../test_v1/test_endpoints/test_files.py | 0 .../test_v1/test_endpoints/test_root.py | 0 .../test_v1/test_services/__init__.py | 0 .../test_course_admin_service.py | 0 .../tests/unit_tests/test_openai_format.py | 0 .../tests/utils.py | 0 234 files changed, 20067 deletions(-) delete mode 100644 ai_course_bot/.gitignore delete mode 100644 ai_course_bot/ai-chatbot/.env.example delete mode 100644 ai_course_bot/ai-chatbot/.eslintrc.json delete mode 100644 ai_course_bot/ai-chatbot/.gitignore delete mode 100755 ai_course_bot/ai-chatbot/Dockerfile delete mode 100755 ai_course_bot/ai-chatbot/LICENSE delete mode 100755 ai_course_bot/ai-chatbot/README.md delete mode 100755 ai_course_bot/ai-chatbot/app/api/auth/[...nextauth]/route.ts delete mode 100755 ai_course_bot/ai-chatbot/app/api/chat/route.ts delete mode 100644 ai_course_bot/ai-chatbot/app/api/chat/save/route.ts delete mode 100755 ai_course_bot/ai-chatbot/app/chat/[id]/page.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/button-scroll-to-bottom.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat-history.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat-list.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat-message-actions.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat-message.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat-panel.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat-scroll-anchor.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat-share-dialog.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/chat.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/clear-history.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/empty-screen.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/external-link.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/footer.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/header.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/login-button.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/markdown.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/prompt-form.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/providers.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/select-course.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-actions.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-desktop.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-footer.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-item.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-items.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-list.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-mobile.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar-toggle.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/sidebar.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/tailwind-indicator.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/theme-toggle.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/alert-dialog.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/badge.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/button.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/codeblock.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/dialog.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/dropdown-menu.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/icons.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/input.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/label.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/select.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/separator.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/sheet.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/switch.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/textarea.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/ui/tooltip.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/components/user-menu.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/lib/hooks/use-at-bottom.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/lib/hooks/use-copy-to-clipboard.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/lib/hooks/use-enter-submit.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/core/lib/hooks/use-local-storage.ts delete mode 100755 ai_course_bot/ai-chatbot/app/core/lib/hooks/use-sidebar.tsx delete mode 100644 ai_course_bot/ai-chatbot/app/core/lib/mongodb.ts delete mode 100755 ai_course_bot/ai-chatbot/app/core/lib/types.ts delete mode 100755 ai_course_bot/ai-chatbot/app/core/lib/utils.ts delete mode 100755 ai_course_bot/ai-chatbot/app/core/utils/actions.ts delete mode 100755 ai_course_bot/ai-chatbot/app/core/utils/auth.ts delete mode 100644 ai_course_bot/ai-chatbot/app/core/utils/eventEmitter.ts delete mode 100755 ai_course_bot/ai-chatbot/app/core/utils/middleware.ts delete mode 100755 ai_course_bot/ai-chatbot/app/globals.css delete mode 100755 ai_course_bot/ai-chatbot/app/layout.tsx delete mode 100644 ai_course_bot/ai-chatbot/app/page.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/share/[id]/page.tsx delete mode 100755 ai_course_bot/ai-chatbot/app/sign-in/page.tsx delete mode 100644 ai_course_bot/ai-chatbot/docker-compose.yml delete mode 100755 ai_course_bot/ai-chatbot/next-env.d.ts delete mode 100755 ai_course_bot/ai-chatbot/next.config.js delete mode 100644 ai_course_bot/ai-chatbot/package-lock.json delete mode 100755 ai_course_bot/ai-chatbot/package.json delete mode 100755 ai_course_bot/ai-chatbot/pnpm-lock.yaml delete mode 100755 ai_course_bot/ai-chatbot/postcss.config.js delete mode 100755 ai_course_bot/ai-chatbot/prettier.config.cjs delete mode 100755 ai_course_bot/ai-chatbot/public/TAI_logo.png delete mode 100755 ai_course_bot/ai-chatbot/public/TAI_prompt.png delete mode 100644 ai_course_bot/ai-chatbot/public/TAI_prompt_circular.png delete mode 100755 ai_course_bot/ai-chatbot/public/apple-touch-icon.png delete mode 100755 ai_course_bot/ai-chatbot/public/favicon-16x16.png delete mode 100755 ai_course_bot/ai-chatbot/public/favicon.ico delete mode 100755 ai_course_bot/ai-chatbot/public/next.svg delete mode 100755 ai_course_bot/ai-chatbot/public/tai_prompt_small.png delete mode 100755 ai_course_bot/ai-chatbot/public/thirteen.svg delete mode 100755 ai_course_bot/ai-chatbot/public/vercel.svg delete mode 100755 ai_course_bot/ai-chatbot/tailwind.config.js delete mode 100755 ai_course_bot/ai-chatbot/tsconfig.json delete mode 100755 ai_course_bot/ai-chatbot/update_and_restart.sh delete mode 100755 ai_course_bot/scripts/build_fe_docker.sh delete mode 100755 ai_course_bot/scripts/run_fe_docker.sh rename {ai_course_bot/ai_chatbot_backend => backend}/.env.example (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/.gitignore (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/README.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/admin/README.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/admin/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/admin/admin.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/deps.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/endpoints/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/endpoints/completions.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/endpoints/course_admin.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/endpoints/courses.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/endpoints/file_completions.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/endpoints/file_tester.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/endpoints/local_files.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/models/files.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/router.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/schemas/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/schemas/completion.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/schemas/course.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/schemas/course_admin.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/schemas/file_completion.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/schemas/files.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/services/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/services/completions_service.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/services/course_admin_service.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/services/courses_service.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/services/rag_retriever.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/services/rag_selector.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/utils/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/api/v1/utils/stream_processing.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/config.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/actions/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/actions/llama_selector.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/actions/llama_seletor.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/actions/model_selector.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/actions/openai_selector.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/data/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/data/fake_chat_completion_data.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/database.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/models/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/models/chat_completion.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/models/courses.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/core/security.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/dependencies/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/dependencies/model.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/dependencies/remote_model.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/services/file_service.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/v1/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/app/v1/openai_mock.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/data/CS61A/documents/code_script/example_code.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/data/CS61A/documents/exams/midterm_sample.pdf (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/data/CS61A/documents/lab_material/01_Getting_Started_Guide.txt (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/data/CS61A/videos/02_Lab_Instructions.mp4.stub (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/data/CS61B/documents/code_script/test_61_code_script.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/docs/FILES_API.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/docs/README.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/docs/api_streaming_reference_guide.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/docs/authentication.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/embeddings.db (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/embeddiongs.db (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/example_cc.txt (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/example_ros_questions.txt (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/main.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/postman/README.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/postman/examples/completion/README.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/postman/examples/completion/cs61a_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/postman/examples/completion/non_rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/postman/examples/completion/rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/postman/examples/completion/streaming_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/postman/files_api_collection.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/pytest.ini (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/requirements.txt (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/scripts/generate_fixtures.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/scripts/generate_postman_collection.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/scripts/initialize_storage.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/scripts/migrate_to_modern_files.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/static/css/file_tester.css (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/static/html/file_tester.html (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/static/js/file_tester.js (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/templates/file_tester.html (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/test.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/test_auth.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/README.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/common/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/common/test_base_classes/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/common/test_base_classes/course_admin_base.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/common/test_utils/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/common/test_utils/openai_format_validation.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/conftest.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/data/embeddings/Berkeley.pkl (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/data/embeddings/backup/Berkeley.pkl (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/data/embeddings/pkl_test_file_generator.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/README.md (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/requests/cs61a_rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/requests/cs61a_streaming_rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/requests/non_rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/requests/rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/requests/streaming_non_rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/requests/streaming_rag_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/responses/cs61a_non_streaming_rag_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/responses/cs61a_streaming_rag_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/responses/non_streaming_non_rag_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/responses/non_streaming_rag_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/responses/streaming_non_rag_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/completions/responses/streaming_rag_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/local_files/requests/get_file_hierarchy_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/local_files/requests/get_file_hierarchy_with_depth_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/local_files/requests/get_file_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/local_files/requests/list_files_request.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/local_files/responses/get_file_hierarchy_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/local_files/responses/get_file_hierarchy_with_depth_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/fixtures/endpoints/local_files/responses/list_files_response.json (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/integration_tests/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/integration_tests/test_api/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/integration_tests/test_api/test_course_admin_endpoints.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/test_fixtures.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/conftest.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_admin_panel/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_admin_panel/test_course_admin_panel.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/test_endpoints/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/test_endpoints/test_completions.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/test_endpoints/test_courses.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/test_endpoints/test_files.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/test_endpoints/test_root.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/test_services/__init__.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_api/test_v1/test_services/test_course_admin_service.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/unit_tests/test_openai_format.py (100%) rename {ai_course_bot/ai_chatbot_backend => backend}/tests/utils.py (100%) diff --git a/ai_course_bot/.gitignore b/ai_course_bot/.gitignore deleted file mode 100644 index fab5a495..00000000 --- a/ai_course_bot/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ai-chatbot-model/state_of_the_union.txt \ No newline at end of file diff --git a/ai_course_bot/ai-chatbot/.env.example b/ai_course_bot/ai-chatbot/.env.example deleted file mode 100644 index ff3c27ae..00000000 --- a/ai_course_bot/ai-chatbot/.env.example +++ /dev/null @@ -1,24 +0,0 @@ -# You must first activate a Billing Account here: https://platform.openai.com/account/billing/overview -# Then get your OpenAI API Key here: https://platform.openai.com/account/api-keys -OPENAI_API_KEY=XXXXXXXX - -# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32` -AUTH_SECRET=XXXXXXXX -# Create a GitHub OAuth app here: https://github.com/settings/applications/new -# For info on authorization callback URL visit here: https://authjs.dev/reference/core/providers_github#callback-url -AUTH_GITHUB_ID=XXXXXXXX -AUTH_GITHUB_SECRET=XXXXXXXX -# Support OAuth login on preview deployments, see: https://authjs.dev/guides/basics/deployment#securing-a-preview-deployment -# Set the following only when deployed. In this example, we can reuse the same OAuth app, but if you are storing users, we recommend using a different OAuth app for development/production so that you don't mix your test and production user base. -# AUTH_REDIRECT_PROXY_URL=https://YOURAPP.vercel.app/api/auth - -# Instructions to create kv database here: https://vercel.com/docs/storage/vercel-kv/quickstart and -KV_URL=XXXXXXXX -KV_REST_API_URL=XXXXXXXX -KV_REST_API_TOKEN=XXXXXXXX -KV_REST_API_READ_ONLY_TOKEN=XXXXXXXX - -SECURE_JWT_CS_61A=XXXXXXX -SECURE_JWT_CS_DATA8=XXXXXXXX -SECURE_JWT_CS_ROAR=XXXXXXX - diff --git a/ai_course_bot/ai-chatbot/.eslintrc.json b/ai_course_bot/ai-chatbot/.eslintrc.json deleted file mode 100644 index c17b5320..00000000 --- a/ai_course_bot/ai-chatbot/.eslintrc.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/eslintrc", - "root": true, - "extends": [ - "next/core-web-vitals", - "prettier", - "plugin:tailwindcss/recommended" - ], - "plugins": ["tailwindcss"], - "rules": { - "tailwindcss/no-custom-classname": "off", - "tailwindcss/classnames-order": "off" - }, - "settings": { - "tailwindcss": { - "callees": ["cn", "cva"], - "config": "tailwind.config.js" - } - }, - "overrides": [ - { - "files": ["*.ts", "*.tsx"], - "parser": "@typescript-eslint/parser" - } - ] -} diff --git a/ai_course_bot/ai-chatbot/.gitignore b/ai_course_bot/ai-chatbot/.gitignore deleted file mode 100644 index dd019e40..00000000 --- a/ai_course_bot/ai-chatbot/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -node_modules -.pnp -.pnp.js - -# testing -coverage - -# next.js -.next/ -out/ -build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# turbo -.turbo - -.env -.vercel -.vscode -.env*.local diff --git a/ai_course_bot/ai-chatbot/Dockerfile b/ai_course_bot/ai-chatbot/Dockerfile deleted file mode 100755 index 6663aad3..00000000 --- a/ai_course_bot/ai-chatbot/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# Use an official Node.js runtime as a parent image -FROM node:18-alpine - -# Set the working directory -WORKDIR /app - -# Copy package.json and package-lock.json (if available) -COPY package*.json ./ - -# Install dependencies -RUN npm install - -# Copy the rest of the application code -COPY . . - -# Build the Next.js application -RUN npm run build - -# Expose the port that your Next.js app runs on -EXPOSE 3000 - -# Define the command to run your Next.js application -CMD ["npm", "run", "start"] -# CMD ["npm", "run", "dev"] diff --git a/ai_course_bot/ai-chatbot/LICENSE b/ai_course_bot/ai-chatbot/LICENSE deleted file mode 100755 index 6c16c29f..00000000 --- a/ai_course_bot/ai-chatbot/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2023 Vercel, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file diff --git a/ai_course_bot/ai-chatbot/README.md b/ai_course_bot/ai-chatbot/README.md deleted file mode 100755 index 9884fa36..00000000 --- a/ai_course_bot/ai-chatbot/README.md +++ /dev/null @@ -1,71 +0,0 @@ - - Next.js 14 and App Router-ready AI chatbot. -

Next.js AI Chatbot

-
- -

- An open-source AI chatbot app template built with Next.js, the Vercel AI SDK, OpenAI, and Vercel KV. -

- -

- Features · - Model Providers · - Deploy Your Own · - Running locally · - Authors -

-
- -## Features - -- [Next.js](https://nextjs.org) App Router -- React Server Components (RSCs), Suspense, and Server Actions -- [Vercel AI SDK](https://sdk.vercel.ai/docs) for streaming chat UI -- Support for OpenAI (default), Anthropic, Cohere, Hugging Face, or custom AI chat models and/or LangChain -- [shadcn/ui](https://ui.shadcn.com) - - Styling with [Tailwind CSS](https://tailwindcss.com) - - [Radix UI](https://radix-ui.com) for headless component primitives - - Icons from [Phosphor Icons](https://phosphoricons.com) -- Chat History, rate limiting, and session storage with [Vercel KV](https://vercel.com/storage/kv) -- [NextAuth.js](https://github.com/nextauthjs/next-auth) for authentication - -## Model Providers - -This template ships with OpenAI `gpt-3.5-turbo` as the default. However, thanks to the [Vercel AI SDK](https://sdk.vercel.ai/docs), you can switch LLM providers to [Anthropic](https://anthropic.com), [Cohere](https://cohere.com/), [Hugging Face](https://huggingface.co), or using [LangChain](https://js.langchain.com) with just a few lines of code. - -## Deploy Your Own - -You can deploy your own version of the Next.js AI Chatbot to Vercel with one click: - -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?demo-title=Next.js+Chat&demo-description=A+full-featured%2C+hackable+Next.js+AI+chatbot+built+by+Vercel+Labs&demo-url=https%3A%2F%2Fchat.vercel.ai%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F4aVPvWuTmBvzM5cEdRdqeW%2F4234f9baf160f68ffb385a43c3527645%2FCleanShot_2023-06-16_at_17.09.21.png&project-name=Next.js+Chat&repository-name=nextjs-chat&repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot&from=templates&skippable-integrations=1&env=OPENAI_API_KEY%2CAUTH_GITHUB_ID%2CAUTH_GITHUB_SECRET%2CAUTH_SECRET&envDescription=How+to+get+these+env+vars&envLink=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot%2Fblob%2Fmain%2F.env.example&teamCreateStatus=hidden&stores=[{"type":"kv"}]) - -## Creating a KV Database Instance - -Follow the steps outlined in the [quick start guide](https://vercel.com/docs/storage/vercel-kv/quickstart#create-a-kv-database) provided by Vercel. This guide will assist you in creating and configuring your KV database instance on Vercel, enabling your application to interact with it. - -Remember to update your environment variables (`KV_URL`, `KV_REST_API_URL`, `KV_REST_API_TOKEN`, `KV_REST_API_READ_ONLY_TOKEN`) in the `.env` file with the appropriate credentials provided during the KV database setup. - -## Running locally - -You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js AI Chatbot. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/projects/environment-variables) for this, but a `.env` file is all that is necessary. - -> Note: You should not commit your `.env` file or it will expose secrets that will allow others to control access to your various OpenAI and authentication provider accounts. - -1. Install Vercel CLI: `npm i -g vercel` -2. Link local instance with Vercel and GitHub accounts (creates `.vercel` directory): `vercel link` -3. Download your environment variables: `vercel env pull` - -```bash -pnpm install -pnpm dev -``` - -Your app template should now be running on [localhost:3000](http://localhost:3000/). - -## Authors - -This library is created by [Vercel](https://vercel.com) and [Next.js](https://nextjs.org) team members, with contributions from: - -- Jared Palmer ([@jaredpalmer](https://twitter.com/jaredpalmer)) - [Vercel](https://vercel.com) -- Shu Ding ([@shuding\_](https://twitter.com/shuding_)) - [Vercel](https://vercel.com) -- shadcn ([@shadcn](https://twitter.com/shadcn)) - [Vercel](https://vercel.com) diff --git a/ai_course_bot/ai-chatbot/app/api/auth/[...nextauth]/route.ts b/ai_course_bot/ai-chatbot/app/api/auth/[...nextauth]/route.ts deleted file mode 100755 index 8cb196fb..00000000 --- a/ai_course_bot/ai-chatbot/app/api/auth/[...nextauth]/route.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { GET, POST } from '@/tai/utils/auth' -export const runtime = 'edge' diff --git a/ai_course_bot/ai-chatbot/app/api/chat/route.ts b/ai_course_bot/ai-chatbot/app/api/chat/route.ts deleted file mode 100755 index 3d19df4e..00000000 --- a/ai_course_bot/ai-chatbot/app/api/chat/route.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { auth } from '@/tai/utils/auth' -import { kv } from '@vercel/kv' -import { nanoid } from '@/tai/lib/utils' - -export const runtime = 'edge' - -export async function POST(req: Request) { - const json = await req.json() - - const { messages, previewToken } = json - var courseId = messages[messages.length - 1].tool_call_id - - const userId: string = (await auth())?.user.email ?? '' - - if (courseId == null || userId == '') { - courseId = 'default' - } - - var apiHost: string = - courseId === 'CS 294-137' - ? process.env['CS_294_137_BACKEND_HOST'] || 'http://0.0.0.0:9000' - : process.env['ROAR_BACKEND_HOST'] || 'http://0.0.0.0:9000' - - const apiUrl: string = apiHost + '/api/chat/completions' - - try { - var body = JSON.stringify({ - course: courseId, - messages, - temperature: 0.7, - stream: true, - userId: userId - }) - - const apiResponse = await fetch(apiUrl, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: body - }) - - if (apiResponse.ok) { - return new Response(apiResponse.body, { - headers: { 'Content-Type': 'application/json' } - }) - } else { - console.log('[Route.ts] API Response Not Ok') - return new Response('Error fetching data', { status: apiResponse.status }) - } - } catch (error) { - console.log('[Route.ts] Error: ', error) - return new Response( - 'Internal Server Error; Server may be down, Please try again later', - { headers: { 'Content-Type': 'application/json' } } - ) - } -} diff --git a/ai_course_bot/ai-chatbot/app/api/chat/save/route.ts b/ai_course_bot/ai-chatbot/app/api/chat/save/route.ts deleted file mode 100644 index 0a1e675a..00000000 --- a/ai_course_bot/ai-chatbot/app/api/chat/save/route.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { nanoid } from '@/tai/lib/utils' -import { auth } from '@/tai/utils/auth' -import { saveChat } from '@/tai/utils/actions' - -export async function POST(req: Request) { - const json = await req.json() - const userId: string = (await auth())?.user.id ?? nanoid() - const title = json.messages[0].content.substring(0, 100) - await saveChat(title, json.messages, userId, json.id) - return new Response() -} diff --git a/ai_course_bot/ai-chatbot/app/chat/[id]/page.tsx b/ai_course_bot/ai-chatbot/app/chat/[id]/page.tsx deleted file mode 100755 index ddea8f77..00000000 --- a/ai_course_bot/ai-chatbot/app/chat/[id]/page.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { type Metadata } from 'next' -import { notFound, redirect } from 'next/navigation' - -import { auth } from '@/tai/utils/auth' -import { getChat } from '@/tai/utils/actions' -import { Chat } from '@/tai/components/chat' - -export interface ChatPageProps { - params: { - id: string - } -} - -export async function generateMetadata({ - params -}: ChatPageProps): Promise { - const session = await auth() - - if (!session?.user) { - return {} - } - - const chat = await getChat(params.id, session.user.id) - return { - title: chat?.title.toString().slice(0, 50) ?? 'Chat' - } -} - -export default async function ChatPage({ params }: ChatPageProps) { - const session = await auth() - - if (!session?.user) { - redirect(`/sign-in?next=/chat/${params.id}`) - } - - const chat = await getChat(params.id, session.user.id) - - if (!chat) { - notFound() - } - - if (chat?.userId !== session?.user?.id) { - notFound() - } - - return -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/button-scroll-to-bottom.tsx b/ai_course_bot/ai-chatbot/app/core/components/button-scroll-to-bottom.tsx deleted file mode 100755 index dabbd1fc..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/button-scroll-to-bottom.tsx +++ /dev/null @@ -1,34 +0,0 @@ -'use client' - -import * as React from 'react' - -import { cn } from '@/tai/lib/utils' -import { useAtBottom } from '@/tai/lib/hooks/use-at-bottom' -import { Button, type ButtonProps } from '@/tai/components/ui/button' -import { IconArrowDown } from '@/tai/components/ui/icons' - -export function ButtonScrollToBottom({ className, ...props }: ButtonProps) { - const isAtBottom = useAtBottom() - - return ( - - ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat-history.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat-history.tsx deleted file mode 100755 index 2877e8fd..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat-history.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import * as React from 'react' - -import Link from 'next/link' - -import { cn } from '@/tai/lib/utils' -import { SidebarList } from '@/tai/components/sidebar-list' -import { buttonVariants } from '@/tai/components/ui/button' -import { IconPlus } from '@/tai/components/ui/icons' -interface ChatHistoryProps { - userId?: string -} - -export async function ChatHistory({ userId }: ChatHistoryProps) { - return ( -
-
- - - New Chat - -
- - {Array.from({ length: 10 }).map((_, i) => ( -
- ))} -
- } - > - {/* @ts-ignore */} - -
-
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat-list.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat-list.tsx deleted file mode 100755 index ffa76152..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat-list.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { type Message } from 'ai' - -import { Separator } from '@/tai/components/ui/separator' -import { ChatMessage } from '@/tai/components/chat-message' - -export interface ChatList { - messages: Message[] -} - -export function ChatList({ messages }: ChatList) { - if (!messages.length) { - return null - } - - return ( -
- {messages.map((message, index) => ( -
- - {index < messages.length - 1 && ( - - )} -
- ))} -
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat-message-actions.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat-message-actions.tsx deleted file mode 100755 index 34b5fa8c..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat-message-actions.tsx +++ /dev/null @@ -1,40 +0,0 @@ -'use client' - -import { type Message } from 'ai' - -import { Button } from '@/tai/components/ui/button' -import { IconCheck, IconCopy } from '@/tai/components/ui/icons' -import { useCopyToClipboard } from '@/tai/lib/hooks/use-copy-to-clipboard' -import { cn } from '@/tai/lib/utils' - -interface ChatMessageActionsProps extends React.ComponentProps<'div'> { - message: Message -} - -export function ChatMessageActions({ - message, - className, - ...props -}: ChatMessageActionsProps) { - const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 }) - - const onCopy = () => { - if (isCopied) return - copyToClipboard(message.content) - } - - return ( -
- -
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat-message.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat-message.tsx deleted file mode 100755 index 5fd44891..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat-message.tsx +++ /dev/null @@ -1,85 +0,0 @@ -// Inspired by Chatbot-UI and modified to fit the needs of this project -// @see https://github.com/mckaywrigley/chatbot-ui/blob/main/components/Chat/ChatMessage.tsx - -import { Message } from 'ai' -import remarkGfm from 'remark-gfm' -import remarkMath from 'remark-math' - -import Image from 'next/image' -import { cn } from '@/tai/lib/utils' -import { CodeBlock } from '@/tai/components/ui/codeblock' -import { MemoizedReactMarkdown } from '@/tai/components/markdown' -import { IconUser } from '@/tai/components/ui/icons' -import { ChatMessageActions } from '@/tai/components/chat-message-actions' - -export interface ChatMessageProps { - message: Message -} - -export function ChatMessage({ message, ...props }: ChatMessageProps) { - return ( -
-
- {message.role === 'user' ? ( - - ) : ( - logo - )} -
-
- {children}

- }, - code({ node, inline, className, children, ...props }) { - if (children.length) { - if (children[0] == '▍') { - return ( - - ) - } - - children[0] = (children[0] as string).replace('`▍`', '▍') - } - - const match = /language-(\w+)/.exec(className || '') - - if (inline) { - return ( - - {children} - - ) - } - - return ( - - ) - } - }} - > - {message.content} -
- -
-
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat-panel.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat-panel.tsx deleted file mode 100755 index f1b267af..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat-panel.tsx +++ /dev/null @@ -1,110 +0,0 @@ -'use client' -import * as React from 'react' -import { type UseChatHelpers } from 'ai/react' - -import { shareChat } from '@/tai/utils/actions' -import { Button } from '@/tai/components/ui/button' -import { PromptForm } from '@/tai/components/prompt-form' -import { ButtonScrollToBottom } from '@/tai/components/button-scroll-to-bottom' -import { IconRefresh, IconShare, IconStop } from '@/tai/components/ui/icons' -import { FooterText } from '@/tai/components/footer' -import { ChatShareDialog } from '@/tai/components/chat-share-dialog' -import { loadData } from '@/tai/lib/utils' -export interface ChatPanelProps - extends Pick< - UseChatHelpers, - | 'append' - | 'isLoading' - | 'reload' - | 'messages' - | 'stop' - | 'input' - | 'setInput' - > { - id?: string - title?: string -} - -export function ChatPanel({ - id, - title, - isLoading, - stop, - append, - reload, - input, - setInput, - messages -}: ChatPanelProps) { - const [shareDialogOpen, setShareDialogOpen] = React.useState(false) - - return ( -
- -
-
- {isLoading ? ( - - ) : ( - messages?.length >= 2 && ( -
- - {id && title ? ( - <> - - setShareDialogOpen(false)} - shareChat={shareChat} - chat={{ - id, - title, - messages - }} - /> - - ) : null} -
- ) - )} -
-
- { - var data = loadData('selectedCourse') - await append({ - id, - content: value, - role: 'user', - tool_call_id: data, - data: data - }) - }} - input={input} - setInput={setInput} - isLoading={isLoading} - /> - {/* */} - -
-
-
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat-scroll-anchor.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat-scroll-anchor.tsx deleted file mode 100755 index bb42555b..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat-scroll-anchor.tsx +++ /dev/null @@ -1,29 +0,0 @@ -'use client' - -import * as React from 'react' -import { useInView } from 'react-intersection-observer' - -import { useAtBottom } from '@/tai/lib/hooks/use-at-bottom' - -interface ChatScrollAnchorProps { - trackVisibility?: boolean -} - -export function ChatScrollAnchor({ trackVisibility }: ChatScrollAnchorProps) { - const isAtBottom = useAtBottom() - const { ref, entry, inView } = useInView({ - trackVisibility, - delay: 100, - rootMargin: '0px 0px -150px 0px' - }) - - React.useEffect(() => { - if (isAtBottom && trackVisibility && !inView) { - entry?.target.scrollIntoView({ - block: 'start' - }) - } - }, [inView, entry, isAtBottom, trackVisibility]) - - return
-} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat-share-dialog.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat-share-dialog.tsx deleted file mode 100755 index 8c74e239..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat-share-dialog.tsx +++ /dev/null @@ -1,106 +0,0 @@ -'use client' - -import * as React from 'react' -import { type DialogProps } from '@radix-ui/react-dialog' -import { toast } from 'react-hot-toast' - -import { ServerActionResult, type Chat } from '@/tai/lib/types' -import { Button } from '@/tai/components/ui/button' -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle -} from '@/tai/components/ui/dialog' -import { IconSpinner } from '@/tai/components/ui/icons' -import { useCopyToClipboard } from '@/tai/lib/hooks/use-copy-to-clipboard' - -interface ChatShareDialogProps extends DialogProps { - chat: Pick - shareChat: (id: string) => ServerActionResult - onCopy: () => void -} - -export function ChatShareDialog({ - chat, - shareChat, - onCopy, - ...props -}: ChatShareDialogProps) { - const { copyToClipboard } = useCopyToClipboard({ timeout: 1000 }) - const [isSharePending, startShareTransition] = React.useTransition() - - const copyShareLink = React.useCallback( - async (chat: Chat) => { - if (!chat.sharePath) { - return toast.error('Could not copy share link to clipboard') - } - - const url = new URL(window.location.href) - url.pathname = chat.sharePath - copyToClipboard(url.toString()) - onCopy() - toast.success('Share link copied to clipboard', { - style: { - borderRadius: '10px', - background: '#333', - color: '#fff', - fontSize: '14px' - }, - iconTheme: { - primary: 'white', - secondary: 'black' - } - }) - }, - [copyToClipboard, onCopy] - ) - - return ( - - - - Share link to chat - - Anyone with the URL will be able to view the shared chat. - - -
-
{chat.title}
-
- {chat.messages.length} messages -
-
- - - -
-
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/chat.tsx b/ai_course_bot/ai-chatbot/app/core/components/chat.tsx deleted file mode 100755 index 9ada1d68..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/chat.tsx +++ /dev/null @@ -1,132 +0,0 @@ -'use client' - -import { useChat, type Message } from 'ai/react' - -import { cn } from '@/tai/lib/utils' -import { ChatList } from '@/tai/components/chat-list' -import { ChatPanel } from '@/tai/components/chat-panel' -import { EmptyScreen } from '@/tai/components/empty-screen' -import { ChatScrollAnchor } from '@/tai/components/chat-scroll-anchor' -import { useLocalStorage } from '@/tai/lib/hooks/use-local-storage' -import { toast } from 'react-hot-toast' -import { usePathname, useRouter } from 'next/navigation' -import { SelectCourse } from '@/tai/components/select-course' -import { useSession } from 'next-auth/react' -import emitter from '@/tai/utils/eventEmitter' - -const IS_PREVIEW = process.env.VERCEL_ENV === 'preview' -export interface ChatProps extends React.ComponentProps<'div'> { - initialMessages?: Message[] - id?: string -} - -export function Chat({ id, initialMessages, className }: ChatProps) { - const { data: session, status } = useSession() - - const router = useRouter() - const path = usePathname() - const [previewToken, setPreviewToken] = useLocalStorage( - 'ai-token', - null - ) - - const saveChat = async ( - prev_messages: Message[], - input: string, - assistant: Message, - id: string | undefined - ) => { - try { - let messages = prev_messages.map(message => { - return { - role: message.role, - content: message.content - } - }) - - messages.push({ - role: 'user', - content: input - }) - - messages.push({ - role: 'assistant', - content: assistant.content - }) - - const response = await fetch('/api/chat/save', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - id, - messages - }) - }) - - if (!response.ok) { - throw new Error('Failed to save chat') - } - - if (!path.includes('chat')) { - window.history.replaceState({}, '', `/chat/${id}`) - router.replace(`/chat/${id}`) - setTimeout(() => { - emitter.emit('historyUpdated') - }, 2000) - } - } catch (error) { - console.error('Error saving chat:', error) - } - } - - const { messages, append, reload, stop, isLoading, input, setInput } = - useChat({ - api: '/api/chat', - initialMessages, - id, - body: { - id, - previewToken - }, - onResponse(response) { - if (response.status === 401) { - toast.error(response.statusText) - } - }, - onFinish(message: Message) { - saveChat(messages, input, message, id) - } - }) - return ( - <> -
-
- {status === 'authenticated' && } -
- - {messages.length ? ( - <> - - - - ) : ( - - )} -
- - - ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/clear-history.tsx b/ai_course_bot/ai-chatbot/app/core/components/clear-history.tsx deleted file mode 100755 index 9e86e5b7..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/clear-history.tsx +++ /dev/null @@ -1,80 +0,0 @@ -'use client' - -import * as React from 'react' -import { useRouter } from 'next/navigation' -import { toast } from 'react-hot-toast' - -import { ServerActionResult } from '@/tai/lib/types' -import { Button } from '@/tai/components/ui/button' -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger -} from '@/tai/components/ui/alert-dialog' -import { IconSpinner } from '@/tai/components/ui/icons' -import { error } from 'console' - -interface ClearHistoryProps { - isEnabled: boolean - clearChats: () => ServerActionResult -} - -export function ClearHistory({ - isEnabled = false, - clearChats -}: ClearHistoryProps) { - const [open, setOpen] = React.useState(false) - const [isPending, startTransition] = React.useTransition() - const router = useRouter() - - return ( - - - - - - - Are you absolutely sure? - - This will permanently delete your chat history and remove your data - from our servers. - - - - Cancel - { - event.preventDefault() - startTransition(() => { - clearChats().then(result => { - if (result && 'error' in result) { - toast.error(result.error) - return - } - - setOpen(false) - - // router.push('/') - window.location.href = '/' - }) - }) - }} - > - {isPending && } - Delete - - - - - ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/empty-screen.tsx b/ai_course_bot/ai-chatbot/app/core/components/empty-screen.tsx deleted file mode 100755 index b7ab6d59..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/empty-screen.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { UseChatHelpers } from 'ai/react' - -import { Button } from '@/tai/components/ui/button' -import { ExternalLink } from '@/tai/components/external-link' -import { IconArrowRight } from '@/tai/components/ui/icons' -import Image from 'next/image' - -const exampleMessages = [ - { - heading: 'Explain course grading system', - message: `What is grading like in this course?` - }, - { - heading: 'Summarize course content', - message: 'Summarize what will I learn in this course \n' - } -] - -export function EmptyScreen({ setInput }: Pick) { - return ( -
-
-
- logo -
-

- Welcome to Teaching Assistant Intelligence -

-

- • You may chat with our public GPT server while remaining anonymous. -

-
- -

- • For Berkeley users with valid campus accounts, you may authenticate - and then chat with private GPT servers that cover teaching assistance - for all supported Berkeley courses. -

-
- -

- • Your questions and private information will never be shared to any - third-party businesses. -

- {/*
- {exampleMessages.map((message, index) => ( - - ))} -
*/} -
-
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/external-link.tsx b/ai_course_bot/ai-chatbot/app/core/components/external-link.tsx deleted file mode 100755 index ba6cc016..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/external-link.tsx +++ /dev/null @@ -1,29 +0,0 @@ -export function ExternalLink({ - href, - children -}: { - href: string - children: React.ReactNode -}) { - return ( - - {children} - - - ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/footer.tsx b/ai_course_bot/ai-chatbot/app/core/components/footer.tsx deleted file mode 100755 index 0a0c1611..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/footer.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' - -import { cn } from '@/tai/lib/utils' -import { ExternalLink } from '@/tai/components/external-link' - -export function FooterText({ className, ...props }: React.ComponentProps<'p'>) { - return ( -

- - This project is fully open sourced on Github - -

- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/header.tsx b/ai_course_bot/ai-chatbot/app/core/components/header.tsx deleted file mode 100755 index 58c69109..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/header.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import * as React from 'react' -import Link from 'next/link' -import { cn } from '@/tai/lib/utils' -import { auth } from '@/tai/utils/auth' -import { Button, buttonVariants } from '@/tai/components/ui/button' -import { IconNextChat, IconSeparator } from '@/tai/components/ui/icons' -import { UserMenu } from '@/tai/components/user-menu' -import { SidebarMobile } from './sidebar-mobile' -import { SidebarToggle } from './sidebar-toggle' -import { ChatHistory } from './chat-history' -import { LoginButton } from '@/tai/components/login-button' -import Image from 'next/image' - -async function UserOrLogin() { - const session = await auth() - return ( - <> - {session?.user ? ( - <> - - - - - - ) : ( - - {/* logo */} - {/* - */} - - )} -
- - {session?.user ? : } -
- - ) -} - -export function Header() { - return ( -
-
- }> - - -
-
- logo -
-
- ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/login-button.tsx b/ai_course_bot/ai-chatbot/app/core/components/login-button.tsx deleted file mode 100755 index 08b934f9..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/login-button.tsx +++ /dev/null @@ -1,42 +0,0 @@ -'use client' - -import * as React from 'react' -import { signIn } from 'next-auth/react' - -import { cn } from '@/tai/lib/utils' -import { Button, type ButtonProps } from '@/tai/components/ui/button' -import { IconSpinner, IconGoogle } from '@/tai/components/ui/icons' - -interface LoginButtonProps extends ButtonProps { - showGoogleIcon?: boolean - text?: string -} - -export function LoginButton({ - text = 'Berkeley Account Login', - showGoogleIcon = false, - className, - ...props -}: LoginButtonProps) { - const [isLoading, setIsLoading] = React.useState(false) - return ( - - ) -} diff --git a/ai_course_bot/ai-chatbot/app/core/components/markdown.tsx b/ai_course_bot/ai-chatbot/app/core/components/markdown.tsx deleted file mode 100755 index d4491467..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/markdown.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { FC, memo } from 'react' -import ReactMarkdown, { Options } from 'react-markdown' - -export const MemoizedReactMarkdown: FC = memo( - ReactMarkdown, - (prevProps, nextProps) => - prevProps.children === nextProps.children && - prevProps.className === nextProps.className -) diff --git a/ai_course_bot/ai-chatbot/app/core/components/prompt-form.tsx b/ai_course_bot/ai-chatbot/app/core/components/prompt-form.tsx deleted file mode 100755 index 918ca142..00000000 --- a/ai_course_bot/ai-chatbot/app/core/components/prompt-form.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import * as React from 'react' -import Textarea from 'react-textarea-autosize' -import { UseChatHelpers } from 'ai/react' -import { useEnterSubmit } from '@/tai/lib/hooks/use-enter-submit' -import { cn } from '@/tai/lib/utils' -import { Button, buttonVariants } from '@/tai/components/ui/button' -import { - Tooltip, - TooltipContent, - TooltipTrigger -} from '@/tai/components/ui/tooltip' -import { IconArrowElbow, IconPlus } from '@/tai/components/ui/icons' -import { useRouter } from 'next/navigation' - -export interface PromptProps - extends Pick { - onSubmit: (value: string) => void - isLoading: boolean -} - -export function PromptForm({ - onSubmit, - input, - setInput, - isLoading -}: PromptProps) { - const { formRef, onKeyDown } = useEnterSubmit() - const inputRef = React.useRef(null) - const router = useRouter() - React.useEffect(() => { - if (inputRef.current) { - inputRef.current.focus() - } - }, []) - - return ( -
{ - e.preventDefault() - if (!input?.trim()) { - return - } - setInput('') - await onSubmit(input) - }} - ref={formRef} - > -
- - - - - New Chat - -