feat: Implement React-TypeScript-Vite frontend with FastAPI backend to have more flexibility compared to Streamlit#10
Draft
umbertogriffo wants to merge 13 commits intomainfrom
Draft
feat: Implement React-TypeScript-Vite frontend with FastAPI backend to have more flexibility compared to Streamlit#10umbertogriffo wants to merge 13 commits intomainfrom
umbertogriffo wants to merge 13 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a new FastAPI backend and a React frontend using TypeScript and Vite, enhancing the chatbot application's flexibility and development environment.
- Introduces a FastAPI app with endpoints and middleware for the backend.
- Sets up a React-based frontend with Material-UI components and configuration files for Vite, ESLint, and TypeScript.
Reviewed Changes
Copilot reviewed 14 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/vite.config.ts | Basic Vite configuration for a React project |
| frontend/src/main.tsx | Initializes the React app and connects it with the root element |
| frontend/src/components/SearchBar.tsx | Implements a search bar with Material-UI, including option toggling |
| frontend/src/components/ChatWindow.tsx | Provides a chat message display component using Material-UI |
| frontend/src/App.tsx | Main application container managing theme, chat messages, and API calls |
| frontend/index.html | Defines the HTML entry point for the React app |
| frontend/eslint.config.js | Configures ESLint for TypeScript and React-related linting |
| frontend/README.md | Outlines instructions for setting up and using the React TypeScript project |
| chatbot/main.py | New FastAPI backend with endpoints, logging, and CORS middleware |
Files not reviewed (7)
- frontend/.gitignore: Language not supported
- frontend/package.json: Language not supported
- frontend/src/App.css: Language not supported
- frontend/src/index.css: Language not supported
- frontend/tsconfig.app.json: Language not supported
- frontend/tsconfig.json: Language not supported
- frontend/tsconfig.node.json: Language not supported
backend/main.py
Outdated
|
|
||
| Code: `code` | ||
|
|
||
| - Go fuck yourself! |
There was a problem hiding this comment.
The markdown response contains unprofessional language which should be removed or replaced to maintain a professional tone in production.
Suggested change
| - Go fuck yourself! | |
| - Thank you for your patience! |
ddecfe0 to
e98e90a
Compare
6bf6e28 to
6c4fb24
Compare
…nd LLM client integration
…nd LLM client integration
* Initial plan * Modernise RAG Chatbot: backend API layer, Tailwind UI, WebSocket streaming, and API tests Co-authored-by: umbertogriffo <1609440+umbertogriffo@users.noreply.github.com> * feat: refactor WebSocket handling and improve error logging in chat stream * feat: refactor WebSocket handling and improve error logging in chat stream * feat: update API endpoints and WebSocket paths for improved routing * feat: update chat endpoint to use LamaCppClient dependency and add comprehensive tests * feat: update chat endpoint to use LamaCppClient dependency and add comprehensive tests * feat: update chat endpoint to use LamaCppClient dependency and add comprehensive tests --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: umbertogriffo <1609440+umbertogriffo@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements to both the backend and frontend of the chatbot application, focusing on enabling true asynchronous, concurrent LLM inference, and scaffolding a new React-based frontend.
The backend now uses thread pools to offload CPU-bound LLM operations, ensuring the event loop remains responsive during concurrent requests.
The frontend is bootstrapped with Vite, React, and TypeScript, including configuration, dependencies, and development documentation.
Backend: Asynchronous LLM Inference and Concurrency Improvements
Refactored the
LamaCppClientand context synthesis strategies to use thread pools for CPU-bound LLM operations, ensuring thread safety and enabling concurrent prompt generation and answer synthesis without blocking the event loop. This includes the use ofthreading.Lockfor model access and the use ofasyncio.get_event_loop().run_in_executorfor all LLM calls.Updated the context synthesis (
AsyncTreeSummarizationStrategy) to generate prompts and answers in parallel using asyncio, significantly improving performance for multi-chunk responses.Removed unnecessary dependencies and blocking event loop hacks (such as
nest_asyncio) in favour of proper asynchronous execution.Backend: API and Application Structure
main.py, including CORS support, health check, and a placeholder/api/chat/endpoint for chatbot queries.Frontend: Project Bootstrapping and Tooling
index.html, andApp.cssfor styling.package.jsonwith dependencies for React, MUI, axios, and development tools..gitignorefor node, logs, and editor files.README.mdwith setup and development instructions.Other Minor Backend Fixes
list(text_batch)for clarity.conversation_handler.pyto useasyncio.runinstead ofget_event_loop().run_until_complete.