-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: Add bundled React webview CLI for local file visualization [wip] #2107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ganeshrvel
wants to merge
3
commits into
explodinggradients:main
Choose a base branch
from
ganeshrvel:poc/packaged-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ downloads/ | |
eggs/ | ||
.eggs/ | ||
lib/ | ||
!webview-poc/ragas-webview/src/lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[project] | ||
name = "ragas" | ||
version = "0.1.0" | ||
description = "Add your description here" | ||
requires-python = ">=3.12" | ||
dependencies = [ | ||
"fastapi>=0.116.1", | ||
"pendulum>=3.0.0", | ||
"ragas-experimental>=0.3.0", | ||
"uvicorn>=0.35.0", | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Python | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*.so | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# Virtual environments | ||
venv/ | ||
env/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# IDE | ||
.vscode/ | ||
.idea/ | ||
*.swp | ||
*.swo | ||
*~ | ||
|
||
# OS | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db | ||
|
||
# Node.js | ||
node_modules/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
# React/Vite | ||
dist/ | ||
dist-ssr/ | ||
*.local | ||
|
||
# Environment variables | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# Logs | ||
logs/ | ||
*.log | ||
|
||
# Coverage | ||
coverage/ | ||
*.lcov | ||
|
||
# ESLint | ||
.eslintcache | ||
|
||
# Prettier | ||
.prettierignore | ||
|
||
# TypeScript | ||
*.tsbuildinfo | ||
|
||
# Temporary files | ||
*.tmp | ||
*.temp | ||
|
||
# Built frontend bundle (generated by build script) | ||
js-bundle/ | ||
private_toolings | ||
!webview-poc/ragas-webview/src/lib | ||
!src/lib | ||
!webview-poc/ragas-webview/src/lib/*/** |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# Ragas Webview CLI | ||
|
||
A web-based file viewer with React frontend and Python backend. Easily spin up a web interface to browse and view local project files. | ||
|
||
## Features | ||
|
||
- 🚀 **Standalone CLI** - Single command to start web server | ||
- ⚛️ **React Frontend** - Modern web interface for file browsing | ||
- 🐍 **Python Backend** - FastAPI server with file serving capabilities | ||
- 🔄 **Development Mode** - Hot reload for both frontend and backend | ||
- 📦 **Production Ready** - Bundled React app served by Python server | ||
|
||
## Installation | ||
|
||
### Using uv (recommended) | ||
|
||
```shell | ||
#For development (both React + Python servers): | ||
uv run python scripts/dev.py <directory> | ||
# uv run python scripts/dev.py ./logs | ||
|
||
#For production (Python server only): | ||
uv run python -m ragas_webview_cli <directory> | ||
# uv run python -m ragas_webview_cli ./logs | ||
|
||
``` | ||
|
||
|
||
```bash | ||
# Install with uv | ||
uv init | ||
|
||
# Or install from local directory | ||
cd webview-poc | ||
uv sync | ||
|
||
uv run python scripts/dev.py | ||
|
||
uv run python -m ragas_webview_cli logs | ||
``` | ||
|
||
### Using pip | ||
|
||
```bash | ||
pip install ragas-webview-cli | ||
|
||
# Or install from local directory | ||
cd webview-poc | ||
pip install -e . | ||
``` | ||
|
||
## Usage | ||
|
||
### Production Mode (Bundled) | ||
|
||
```bash | ||
# Start the webview server | ||
uv run ragas-webview-cli --port 8000 --host 127.0.0.1 | ||
ganeshrvel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Or use Python directly | ||
uv run python -m ragas_webview_cli.cli --port 8000 | ||
``` | ||
|
||
### Development Mode | ||
|
||
```bash | ||
# Run both React dev server and Python API server | ||
uv run python scripts/dev.py | ||
|
||
# This starts: | ||
# - React dev server on http://localhost:3000 (with hot reload) | ||
# - Python API server on http://localhost:8000 | ||
``` | ||
|
||
### Building React Bundle | ||
|
||
```bash | ||
# Build React app for production | ||
uv run python scripts/build.py | ||
|
||
# Or build directly with npm | ||
cd ragas-webview | ||
npm run build:bundle | ||
``` | ||
|
||
## Development Setup | ||
|
||
### Prerequisites | ||
|
||
- Python 3.9+ | ||
- Node.js 18+ | ||
- uv (recommended) or pip | ||
|
||
### Setup | ||
|
||
```bash | ||
# Clone and setup with uv | ||
git clone <repo> | ||
ganeshrvel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cd webview-poc | ||
uv sync | ||
|
||
# Install React dependencies | ||
cd ragas-webview | ||
npm install | ||
cd .. | ||
|
||
# Run development environment | ||
uv run python scripts/dev.py | ||
``` | ||
|
||
## Project Structure | ||
|
||
``` | ||
webview-poc/ | ||
├── README.md | ||
├── pyproject.toml # ← Package configuration | ||
├── uv.lock # ← UV lock file | ||
├── js-bundle/ # ← Built React app (not packaged) | ||
├── ragas-webview/ # ← React source (not packaged) | ||
├── scripts/ # ← Development scripts (not packaged) | ||
│ ├── dev.py # ← Development server script | ||
│ └── build.py # ← Build script | ||
└── ragas_webview_cli/ # ← Main package (packaged in pip) | ||
├── __init__.py | ||
├── cli.py # ← CLI entry point | ||
├── config.py # ← Configuration | ||
└── server.py # ← FastAPI server | ||
``` | ||
|
||
## Configuration | ||
|
||
All server ports and hosts are configured in `ragas_webview_cli/config.py`: | ||
|
||
```python | ||
BACKEND_PORT = 8000 | ||
FRONTEND_PORT = 3000 | ||
BACKEND_HOST = "127.0.0.1" | ||
FRONTEND_HOST = "127.0.0.1" | ||
``` | ||
|
||
## API Endpoints | ||
|
||
- `GET /` - Serves React app (production) or API info (development) | ||
- `GET /api/health` - Health check endpoint | ||
- `GET /assets/*` - Static assets (CSS, JS, images) | ||
ganeshrvel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## License | ||
|
||
MIT License |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[project] | ||
name = "ragas-webview-cli" | ||
version = "0.1.0" | ||
description = "Web-based file viewer with React frontend and Python backend" | ||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
authors = [ | ||
{name = "Ragas Team", email = "[email protected]"} | ||
] | ||
keywords = ["webview", "file-viewer", "react", "fastapi"] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
] | ||
|
||
dependencies = [ | ||
"fastapi>=0.100.0", | ||
"uvicorn[standard]>=0.23.0", | ||
"typer>=0.9.0", | ||
"pydantic>=2.0.0", | ||
"pendulum>=3.0.0", | ||
] | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"pytest>=7.0.0", | ||
"pytest-asyncio>=0.21.0", | ||
"httpx>=0.24.0", # For testing FastAPI | ||
"black>=23.0.0", | ||
"ruff>=0.1.0", | ||
] | ||
ganeshrvel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# No scripts - use python -m ragas_webview_cli.cli or direct import | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["ragas_webview_cli"] | ||
ganeshrvel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[tool.uv] | ||
dev-dependencies = [ | ||
"pytest>=7.0.0", | ||
"pytest-asyncio>=0.21.0", | ||
"httpx>=0.24.0", | ||
"black>=23.0.0", | ||
"ruff>=0.1.0", | ||
] | ||
|
||
# Removed ragas-experimental dependency | ||
|
||
[tool.ruff] | ||
select = ["E", "F", "I"] | ||
ignore = ["E501"] | ||
line-length = 88 | ||
target-version = "py39" | ||
|
||
[tool.black] | ||
line-length = 88 | ||
target-version = ["py39"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
!webview-poc/ragas-webview/src/lib/*/** | ||
!lib/*/** |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import("prettier").Config} */ | ||
module.exports = { | ||
semi: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
tabWidth: 2, | ||
useTabs: false, | ||
bracketSpacing: true, | ||
arrowParens: 'always', | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.