Skip to content
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

0.1.10 #174

Merged
merged 42 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c662ca8
feat: enhance package installation UI with spinner and better error h…
lavishsaluja Nov 17, 2024
9230371
refactor: move test_install_ui.py to tests directory
lavishsaluja Nov 17, 2024
429a4e5
ui: improve install success message styling
lavishsaluja Nov 17, 2024
02cdf26
ui: refine installation success message styling
lavishsaluja Nov 17, 2024
0fd65bd
refactor: restructure install UI
lavishsaluja Nov 17, 2024
34ca6fb
init commit
CharlieJCJ Nov 19, 2024
9fccd89
add logging for created and finished at
CharlieJCJ Nov 19, 2024
e4c8541
logging created time and finished time in openai online + batch
CharlieJCJ Nov 19, 2024
6650a4e
add in datasetviewer
CharlieJCJ Nov 19, 2024
b971778
add in detail sidebar view
CharlieJCJ Nov 19, 2024
6e860f2
adjust docstring in generic response
CharlieJCJ Nov 19, 2024
9e14c45
added timeseries chart; dark mode color fixes
CharlieJCJ Nov 19, 2024
64f9715
default to requests & responses; title adjusts in button and time ser…
CharlieJCJ Nov 19, 2024
f7b25d4
removed unused imports
CharlieJCJ Nov 19, 2024
0187d1e
fix coloring
CharlieJCJ Nov 19, 2024
ec1cbfb
button name
CharlieJCJ Nov 20, 2024
d28a5f8
remove unneeded variables
CharlieJCJ Nov 20, 2024
40aa7df
remove border
CharlieJCJ Nov 20, 2024
a7bd44e
npm audit fix
CharlieJCJ Nov 20, 2024
96386ca
Prism and npm audit install
CharlieJCJ Nov 20, 2024
bb2a264
table unique key issue address, including rowIndex as part of the key
CharlieJCJ Nov 20, 2024
87a9a1e
fixed trung's comment
CharlieJCJ Nov 20, 2024
72d2d68
Merge pull request #149 from bespokelabsai/CURATOR-43-add-time-loggin…
vutrung96 Nov 20, 2024
dfe084c
Merge pull request #134 from lavishsaluja/feature/enhanced-install-ui
vutrung96 Nov 20, 2024
5ac1844
Merge branch 'dev' of https://github.com/bespokelabsai/bella into dev
CharlieJCJ Nov 20, 2024
dea90d4
add logging for cost and tokens
CharlieJCJ Nov 20, 2024
201fca1
disabled generic try catch
CharlieJCJ Nov 20, 2024
ec424e7
Merge pull request #159 from bespokelabsai/CURATOR-44-add-cost-loggin…
vutrung96 Nov 21, 2024
0d9c69b
replace function source caching with dill pickling
vutrung96 Nov 21, 2024
377ec27
bytesio
vutrung96 Nov 21, 2024
34bf3d7
push loop test
vutrung96 Nov 21, 2024
18c6cbc
add test
vutrung96 Nov 21, 2024
b7f0503
remove files + black
vutrung96 Nov 21, 2024
5380c96
add isort and black and github workflows
vutrung96 Nov 21, 2024
c631a90
fix directory
vutrung96 Nov 21, 2024
f9ac281
remove projects
vutrung96 Nov 21, 2024
206058b
black
vutrung96 Nov 21, 2024
ab724e2
use black only for now
vutrung96 Nov 21, 2024
9ec38e8
Merge pull request #168 from bespokelabsai/trung/formatting
vutrung96 Nov 21, 2024
82ced1a
Merge branch 'dev' of https://github.com/bespokelabsai/curator into t…
vutrung96 Nov 21, 2024
94111a4
add nested calling test
vutrung96 Nov 21, 2024
14bd655
Merge pull request #167 from bespokelabsai/trung/code-object
vutrung96 Nov 21, 2024
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
21 changes: 21 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Python Linting

on: [push, pull_request]

jobs:
PythonLinting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Run black
run: |
poetry run black --check .
7 changes: 7 additions & 0 deletions bespoke-dataset-viewer/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ body {
--chart-5: 27 87% 67%;
--radius: 0.5rem;
--success: 142 40% 75%;
--tooltip-bg: white;
--tooltip-text-bg: rgb(255, 255, 255);
--tooltip-text: black;
}
.dark {
--background: 0 0% 3.9%;
Expand Down Expand Up @@ -61,6 +64,10 @@ body {
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
--success: 142 72% 40%; /* Slightly brighter green for dark mode */
--tooltip-bg: rgb(90, 90, 90);
--tooltip-text-bg: rgb(0, 0, 0);
--tooltip-text: rgb(250, 250, 250);
--border: rgb(39, 39, 42);
}
}

Expand Down
70 changes: 42 additions & 28 deletions bespoke-dataset-viewer/components/dataset-viewer/DatasetViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import { FileText, Loader2, RefreshCcw } from "lucide-react"
import { useCallback, useEffect, useState } from "react"
import { DetailsSidebar } from "./DetailsSidebar"
import { DistributionChart } from "./DistributionChart"
import { TimeSeriesChart } from './TimeSeriesChart'

const COLUMNS: Column[] = [
{ key: "user_message", label: "User Message" },
{ key: "assistant_message", label: "Assistant Message" },
{ key: "prompt_tokens", label: "Prompt Tokens" },
{ key: "completion_tokens", label: "Completion Tokens" }
{ key: "completion_tokens", label: "Completion Tokens" },
{ key: "generation_time", label: "Generation Time (s)" }
]

interface DatasetViewerProps {
Expand Down Expand Up @@ -61,7 +63,7 @@ export function DatasetViewer({ runHash, batchMode }: DatasetViewerProps) {
const [data, setData] = useState<DataItem[]>([])
const [theme, setTheme] = useState<"light" | "dark">("light")
const [mounted, setMounted] = useState(false)
const [selectedDistribution, setSelectedDistribution] = useState<string | null>("total_tokens")
const [selectedDistribution, setSelectedDistribution] = useState<string | null>("requests")
const [selectedItem, setSelectedItem] = useState<DataItem | null>(null)
const { toast } = useToast()
const [isPolling, setIsPolling] = useState(false)
Expand Down Expand Up @@ -224,29 +226,37 @@ export function DatasetViewer({ runHash, batchMode }: DatasetViewerProps) {
<p className="text-sm text-muted-foreground">View and analyze your dataset responses</p>
</div>
{data.length > 0 && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline">
{selectedDistribution
? selectedDistribution.split('_').map(word =>
word.charAt(0).toUpperCase() + word.slice(1)
).join(' ')
: 'Select Metric'}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setSelectedDistribution(null)}>
None
</DropdownMenuItem>
{["total_tokens", "prompt_tokens", "completion_tokens"].map((column) => (
<DropdownMenuItem key={column} onClick={() => setSelectedDistribution(column)}>
{column === "total_tokens" ? "Total Tokens" :
column === "prompt_tokens" ? "Prompt Tokens" :
"Completion Tokens"}
<div className="flex gap-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline">
{selectedDistribution
? selectedDistribution === "requests"
? "Requests & Responses"
: selectedDistribution.split('_').map(word =>
word.charAt(0).toUpperCase() + word.slice(1)
).join(' ')
: 'Select Metric'}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setSelectedDistribution(null)}>
None
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
<DropdownMenuItem onClick={() => setSelectedDistribution("requests")}>
Requests & Responses
</DropdownMenuItem>
{["total_tokens", "prompt_tokens", "completion_tokens", "generation_time"].map((column) => (
<DropdownMenuItem key={column} onClick={() => setSelectedDistribution(column)}>
{column === "total_tokens" ? "Total Tokens" :
column === "prompt_tokens" ? "Prompt Tokens" :
column === "completion_tokens" ? "Completion Tokens" :
"Generation Time (s)"}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</div>
)}
</div>

Expand All @@ -264,10 +274,14 @@ export function DatasetViewer({ runHash, batchMode }: DatasetViewerProps) {
<div className="mb-8 space-y-4">
{selectedDistribution && (
<div className="rounded-lg border bg-card p-4">
<DistributionChart
data={data}
column={selectedDistribution}
/>
{selectedDistribution === "requests" ? (
<TimeSeriesChart data={data} />
) : (
<DistributionChart
data={data}
column={selectedDistribution}
/>
)}
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ export function DetailsSidebar({ item, onClose }: DetailsSidebarProps) {
</div>
</div>
</div>
<Separator />
<div className="space-y-2">
<h3 className="text-lg font-semibold">Generation Time</h3>
<p className="text-2xl font-bold">
{((new Date(item.finished_at).getTime() - new Date(item.created_at).getTime()) / 1000).toFixed(2)}s
</p>
</div>
</CardContent>
</div>
</div>
Expand Down
104 changes: 27 additions & 77 deletions bespoke-dataset-viewer/components/dataset-viewer/DistributionChart.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client"

import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts'
import { bin } from 'd3-array'
import { DataItem } from '@/types/dataset'

interface DistributionChartProps {
Expand All @@ -11,43 +12,8 @@ interface DistributionChartProps {
const COLUMN_DISPLAY_NAMES: Record<string, string> = {
total_tokens: "Total Tokens",
prompt_tokens: "Prompt Tokens",
completion_tokens: "Completion Tokens"
}

function calculateNiceBinSize(min: number, max: number): { binSize: number, start: number, end: number } {
// Calculate the range
const range = max - min;

// Get the magnitude of the range (in powers of 10)
const magnitude = Math.floor(Math.log10(range));

// Possible bin sizes (1, 2, 5, 10) * 10^n
const base = Math.pow(10, magnitude);
const possibleBinSizes = [
0.1 * base,
0.2 * base,
0.5 * base,
base,
2 * base,
5 * base,
10 * base
];

// Aim for between 5-10 bins
const targetBins = 7;

// Find the bin size that gives us closest to our target number of bins
const binSize = possibleBinSizes.reduce((prev, curr) => {
const prevBins = range / prev;
const currBins = range / curr;
return Math.abs(currBins - targetBins) < Math.abs(prevBins - targetBins) ? curr : prev;
});

// Calculate nice start and end points
const start = Math.floor(min / binSize) * binSize;
const end = Math.ceil(max / binSize) * binSize;

return { binSize, start, end };
completion_tokens: "Completion Tokens",
generation_time: "Generation Time (s)"
}

function getDistributionData(data: DataItem[], column: string) {
Expand All @@ -59,53 +25,25 @@ function getDistributionData(data: DataItem[], column: string) {
return item.raw_response.usage?.prompt_tokens || item.raw_response.response?.body?.usage?.prompt_tokens || 0;
case "completion_tokens":
return item.raw_response.usage?.completion_tokens || item.raw_response.response?.body?.usage?.completion_tokens || 0;
case "generation_time":
return (new Date(item.finished_at).getTime() - new Date(item.created_at).getTime()) / 1000;
default:
return 0;
}
});

const min = Math.min(...values);
const max = Math.max(...values);
const binner = bin()
.value(d => d)
.thresholds(10);

// If min equals max, all values are the same
if (min === max) {
return [{
range: `${min}`,
count: values.length
}];
}

const { binSize, start, end } = calculateNiceBinSize(min, max);
const numBins = Math.ceil((end - start) / binSize);

// Initialize buckets
const buckets: { range: string; start: number; count: number }[] = [];
for (let i = 0; i < numBins; i++) {
const bucketStart = start + (i * binSize);
const bucketEnd = bucketStart + binSize;
buckets.push({
range: `${Math.round(bucketStart)}-${Math.round(bucketEnd)}`,
start: bucketStart,
count: 0
});
}

// Count values in buckets
values.forEach(value => {
const bucketIndex = Math.floor((value - start) / binSize);
if (bucketIndex >= 0 && bucketIndex < buckets.length) {
buckets[bucketIndex].count++;
}
});
const bins = binner(values);

// Only return buckets that have counts
return buckets
.filter(bucket => bucket.count > 0)
.sort((a, b) => a.start - b.start)
.map(({ range, count }) => ({
range,
count
}));
return bins.map(b => ({
range: Number.isInteger(b.x0) ? `${b.x0}` : `${b.x0?.toFixed(2)}`,
count: b.length,
start: b.x0,
end: b.x1
}));
}

export function DistributionChart({ data, column }: DistributionChartProps) {
Expand Down Expand Up @@ -133,6 +71,18 @@ export function DistributionChart({ data, column }: DistributionChartProps) {
<YAxis />
<Tooltip
formatter={(value: number) => [`Count: ${value}`, displayName]}
contentStyle={{
backgroundColor: 'var(--tooltip-text-bg)',
border: '1px solid var(--border)',
borderRadius: '4px',
color: 'var(--tooltip-text)',
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
}}
labelStyle={{
color: 'var(--tooltip-text)',
marginBottom: '4px'
}}
cursor={{ fill: 'var(--tooltip-bg)', opacity: 0.2 }}
/>
<Bar
dataKey="count"
Expand Down
Loading