Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ seed:
.PHONY: seed-cleanup
seed-cleanup:
python hack/seed.py cleanup

build-dashboard:
rm -rf alphatrion/static/*
cd dashboard && npm install && npm run build
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ HostName: postgres
ServerPWD: alphatr1on
```

### Run a Sample Experiment
### Run a Simple Experiment

Below is a simple example with two approaches demonstrating how to create an experiment and log performance metrics.

Expand All @@ -75,27 +75,25 @@ async with alpha.CraftExperiment.setup(name="my_experiment") as exp:
await run.wait()
```

### View Results
### View Dashboard

The dashboard is under active development.
The dashboard is under active development.
You can already run the frontend locally to explore experiments, trials, runs, and metrics through the UI.

### Prerequisites
Make sure the following are installed:

- **Node.js ≥ 18**
- **npm ≥ 9**
- **npm ≥ 9**
- **Vite**
- Backend (`alphatrion server`) running

### Running the Frontend
### Launch Dashboard

Inside the `dashboard` directory:
```bash
npm install
npm run dev
alphatrion server # Start the backend server
alphatrion dashboard # Start the dashboard
```
Dashboard is available at `http://localhost:5173`
Dashboard is available at `http://localhost:3000` by default.

### Cleanup

Expand Down
31 changes: 30 additions & 1 deletion alphatrion/server/cmd/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import argparse
import os
import webbrowser
from pathlib import Path

import uvicorn
from dotenv import load_dotenv
from fastapi import FastAPI
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
from rich.console import Console
from rich.text import Text

Expand All @@ -24,7 +30,11 @@ def main():
)
server.set_defaults(func=run_server)

# Reserve for dashboard command in the future
dashboard = subparsers.add_parser("dashboard", help="Run the AlphaTrion dashboard")
dashboard.add_argument(
"--port", type=int, default=3000, help="Port to run the dashboard on"
)
dashboard.set_defaults(func=start_dashboard)

args = parser.parse_args()
args.func(args)
Expand All @@ -38,3 +48,22 @@ def run_server(args):
console.print(msg)
graphql_init()
uvicorn.run("alphatrion.server.cmd.app:app", host=args.host, port=args.port)


def start_dashboard(args):
static_path = Path(__file__).resolve().parents[2] / "static"

app = FastAPI()
app.mount("/static", StaticFiles(directory=static_path, html=True), name="static")

@app.get("/{full_path:path}")
def spa_fallback(full_path: str):
index_file = os.path.join(static_path, "index.html")
if os.path.exists(index_file):
return FileResponse(index_file)
return {"error": "index.html not found"}

url = f"http://localhost:{args.port}"
webbrowser.open(url)

uvicorn.run(app, host="127.0.0.1", port=args.port)
Binary file added alphatrion/static/alphatrion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions alphatrion/static/assets/index-CZjEehIf.css

Large diffs are not rendered by default.

226 changes: 226 additions & 0 deletions alphatrion/static/assets/index-DzgxcILT.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions alphatrion/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LLM Observatory</title>
<script type="module" crossorigin src="/static/assets/index-DzgxcILT.js"></script>
<link rel="stylesheet" crossorigin href="/static/assets/index-CZjEehIf.css">
</head>

<body>
<div id="root"></div>
<!-- Vite entry points to src/main.tsx -->
</body>

</html>
Binary file added alphatrion/static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions dashboard/src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function App() {
<div className="flex justify-center items-center h-screen">
<div className="relative">
<div className="w-16 h-16 border-4 border-indigo-200 rounded-full animate-spin border-t-indigo-600"></div>
<img src="/logo.png" alt="Loading" className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6" />
<img src="/static/logo.png" alt="Loading" className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6" />
</div>
</div>
);
Expand Down Expand Up @@ -127,17 +127,17 @@ function App() {
<div className="flex h-screen">
{/* Sidebar */}
<div
className={`${sidebarOpen ? "w-64" : "w-19"}
transition-all duration-300 flex-shrink-0
bg-white/70 backdrop-blur-xl
className={`${sidebarOpen ? "w-64" : "w-19"}
transition-all duration-300 flex-shrink-0
bg-white/70 backdrop-blur-xl
border-r border-gray-200/50
shadow-[1px_0_30px_-15px_rgba(0,0,0,0.1)]`}
>
<div className="flex flex-col h-full">
{/* Logo */}
<div className="flex items-center justify-between h-16 px-3 border-b border-gray-200/50">
<div className="flex items-center gap-3">
<img src="/logo.png" alt="Alphatrion" className="w-9 h-9 rounded-xl flex-shrink-0" />
<img src="/static/logo.png" alt="AlphaTrion" className="w-9 h-9 rounded-xl flex-shrink-0" />
{sidebarOpen && (
<span className="font-bold text-lg bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent">
AlphaTrion
Expand Down Expand Up @@ -170,7 +170,7 @@ function App() {
setSelectedTrialId(null);
navigate(`/experiments?projectId=${id}`);
}}
className="mt-2 block w-full px-3 py-2 text-sm bg-gray-50/80 border border-gray-200 rounded-lg
className="mt-2 block w-full px-3 py-2 text-sm bg-gray-50/80 border border-gray-200 rounded-lg
focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-400
transition-all cursor-pointer hover:bg-gray-100/80"
>
Expand All @@ -183,7 +183,7 @@ function App() {
</div>
) : (
<div
className="w-10 h-10 bg-gradient-to-br from-gray-100 to-gray-50 rounded-lg flex items-center justify-center
className="w-10 h-10 bg-gradient-to-br from-gray-100 to-gray-50 rounded-lg flex items-center justify-center
text-indigo-600 text-sm font-semibold cursor-pointer border border-gray-200
hover:shadow-md transition-all mx-auto"
title={selectedProject?.name || "Select Project"}
Expand Down
4 changes: 4 additions & 0 deletions dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
base: "/static/",
plugins: [react()],
build: {
outDir: "../alphatrion/static",
},
});
Loading