├── lib ├── util │ ├── util │ │ ├── py.typed │ │ ├── __init__.py │ │ ├── print_loud.py │ │ ├── errors.py │ │ ├── types.py │ │ ├── data.py │ │ ├── malloc.py │ │ ├── gpu.py │ │ ├── huggingface.py │ │ ├── neurons_split.py │ │ ├── env.py │ │ ├── dataset.py │ │ ├── anthropic.py │ │ ├── activations.py │ │ └── prod_llms.py │ └── pyproject.toml ├── neurondb │ ├── neurondb │ │ ├── __init__.py │ │ ├── py.typed │ │ └── schemas │ │ │ ├── base.py │ │ │ ├── indices.py │ │ │ ├── __init__.py │ │ │ └── tables.py │ ├── Fresh.Dockerfile │ ├── pyproject.toml │ ├── FromBackup.Dockerfile │ └── README.md ├── activations │ ├── activations │ │ ├── py.typed │ │ ├── activations_computation.py │ │ ├── activations.py │ │ ├── exemplars.py │ │ └── test_exemplars_computation.py │ └── pyproject.toml ├── explanations │ ├── explanations │ │ ├── py.typed │ │ └── explainer.py │ └── pyproject.toml ├── investigator │ ├── investigator │ │ ├── py.typed │ │ └── summarization.py │ ├── README.md │ └── pyproject.toml └── lucepkg │ └── scripts │ └── nb_kernel.sh ├── project ├── expgen │ ├── scripts │ │ ├── __init__.py │ │ └── compute_exemplars.py │ ├── pyproject.toml │ ├── configs │ │ └── distilled_llama.yaml │ └── README.md └── monitor │ ├── web │ ├── .eslintrc.json │ ├── app │ │ ├── favicon.ico │ │ ├── page.tsx │ │ ├── types │ │ │ ├── tokens.ts │ │ │ ├── neuronFilters.ts │ │ │ └── neuronData.ts │ │ ├── constants.ts │ │ ├── dashboard │ │ │ ├── page.tsx │ │ │ ├── status │ │ │ │ └── page.tsx │ │ │ └── layout.tsx │ │ ├── store │ │ │ ├── api │ │ │ │ ├── sessionApi.ts │ │ │ │ ├── neuronsApi.ts │ │ │ │ └── chatApi.ts │ │ │ ├── store.ts │ │ │ └── slices │ │ │ │ ├── steeringSlice.ts │ │ │ │ ├── chatSlice.ts │ │ │ │ ├── uiStateSlice.ts │ │ │ │ ├── aiLinterSlice.ts │ │ │ │ └── neuronsSlice.ts │ │ ├── providers.tsx │ │ ├── layout.tsx │ │ └── globals.css │ ├── next.config.mjs │ ├── .prettierrc.json │ ├── postcss.config.mjs │ ├── lib │ │ └── utils.ts │ ├── components │ │ └── ui │ │ │ ├── skeleton.tsx │ │ │ ├── label.tsx │ │ │ ├── textarea.tsx │ │ │ ├── input.tsx │ │ │ ├── toaster.tsx │ │ │ ├── slider.tsx │ │ │ ├── checkbox.tsx │ │ │ ├── switch.tsx │ │ │ ├── badge.tsx │ │ │ ├── popover.tsx │ │ │ ├── tooltip.tsx │ │ │ ├── alert.tsx │ │ │ ├── resizable.tsx │ │ │ ├── button.tsx │ │ │ ├── tabs.tsx │ │ │ ├── card.tsx │ │ │ ├── pagination.tsx │ │ │ ├── table.tsx │ │ │ ├── drawer.tsx │ │ │ ├── dialog.tsx │ │ │ ├── toast.tsx │ │ │ └── select.tsx │ ├── hooks │ │ ├── use-debounce.ts │ │ └── use-toast.ts │ ├── components.json │ ├── .gitignore │ ├── public │ │ ├── vercel.svg │ │ └── next.svg │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── tailwind.config.ts │ ├── scripts │ ├── download_llm.py │ ├── web.sh │ ├── api.sh │ └── neurondb.sh │ ├── pyproject.toml │ ├── monitor │ └── server_modal.py │ └── README.md ├── .root ├── .vscode ├── settings.json └── observatory.code-workspace ├── .env.template ├── pyproject.toml ├── LICENSE ├── .pre-commit-config.yaml ├── .gitignore └── README.md /lib/util/util/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/util/util/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/neurondb/neurondb/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/neurondb/neurondb/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/activations/activations/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/explanations/explanations/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/investigator/investigator/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /project/expgen/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/investigator/README.md: -------------------------------------------------------------------------------- 1 | ## Investigator 2 | -------------------------------------------------------------------------------- /.root: -------------------------------------------------------------------------------- 1 | This file indicates the root of the project. 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.analysis.typeCheckingMode": "strict" 3 | } 4 | -------------------------------------------------------------------------------- /project/monitor/web/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /project/monitor/web/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransluceAI/observatory/HEAD/project/monitor/web/app/favicon.ico -------------------------------------------------------------------------------- /project/monitor/web/next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {}; 3 | 4 | export default nextConfig; 5 | -------------------------------------------------------------------------------- /project/monitor/web/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": true, 4 | "tabWidth": 2, 5 | "trailingComma": "es5" 6 | } 7 | -------------------------------------------------------------------------------- /project/monitor/web/app/page.tsx: -------------------------------------------------------------------------------- 1 | import { redirect } from 'next/navigation'; 2 | 3 | export default function Home() { 4 | redirect('/dashboard'); 5 | } 6 | -------------------------------------------------------------------------------- /lib/util/util/print_loud.py: -------------------------------------------------------------------------------- 1 | def print_loud(x: str): 2 | width = len(x) + 4 3 | print("-" * width) 4 | print(f"| {x} |") 5 | print("-" * width) 6 | -------------------------------------------------------------------------------- /project/monitor/web/app/types/tokens.ts: -------------------------------------------------------------------------------- 1 | export interface ChatToken { 2 | token: string; 3 | so_lens_highlight?: number; 4 | top_log_probs?: [string, number][]; 5 | } 6 | -------------------------------------------------------------------------------- /project/monitor/web/app/constants.ts: -------------------------------------------------------------------------------- 1 | export const BASE_URL = process.env.NEXT_PUBLIC_API_HOST; 2 | if (!BASE_URL) { 3 | throw new Error('NEXT_PUBLIC_API_HOST is not set'); 4 | } 5 | -------------------------------------------------------------------------------- /project/monitor/web/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /lib/util/util/errors.py: -------------------------------------------------------------------------------- 1 | class DBTimeoutException(Exception): 2 | pass 3 | 4 | 5 | class EmbeddingException(Exception): 6 | pass 7 | 8 | 9 | class LlmApiException(Exception): 10 | pass 11 | -------------------------------------------------------------------------------- /project/monitor/web/lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { clsx, type ClassValue } from "clsx" 2 | import { twMerge } from "tailwind-merge" 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)) 6 | } 7 | -------------------------------------------------------------------------------- /.env.template: -------------------------------------------------------------------------------- 1 | OPENAI_API_ORG= 2 | OPENAI_API_KEY= 3 | ANTHROPIC_API_KEY= 4 | 5 | HF_TOKEN= 6 | 7 | PG_USER= 8 | PG_PASSWORD= 9 | PG_HOST= 10 | PG_PORT= 11 | PG_DATABASE= 12 | -------------------------------------------------------------------------------- /project/monitor/scripts/download_llm.py: -------------------------------------------------------------------------------- 1 | from transformers import AutoModelForCausalLM, AutoTokenizer 2 | from util.env import ENV 3 | 4 | HF_TOKEN = ENV.HF_TOKEN 5 | MODEL_REPO = "meta-llama/llama-3.1-8b-instruct" 6 | 7 | tokenizer = AutoTokenizer.from_pretrained(MODEL_REPO) 8 | model = AutoModelForCausalLM.from_pretrained(MODEL_REPO) 9 | -------------------------------------------------------------------------------- /project/monitor/web/app/dashboard/page.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import { useEffect } from 'react'; 4 | import { useRouter } from 'next/navigation'; 5 | 6 | export default function DashboardPage() { 7 | const router = useRouter(); 8 | 9 | useEffect(() => { 10 | router.push('/dashboard/chat'); 11 | }, [router]); 12 | 13 | return null; 14 | } 15 | -------------------------------------------------------------------------------- /project/monitor/web/components/ui/skeleton.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from "@/lib/utils" 2 | 3 | function Skeleton({ 4 | className, 5 | ...props 6 | }: React.HTMLAttributes) { 7 | return ( 8 |
12 | ) 13 | } 14 | 15 | export { Skeleton } 16 | -------------------------------------------------------------------------------- /lib/neurondb/neurondb/schemas/base.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy.orm import DeclarativeBase 2 | 3 | 4 | class SQLABase(DeclarativeBase): 5 | def dict(self): 6 | return {c.key: getattr(self, c.key) for c in self.__table__.columns} 7 | 8 | def __repr__(self) -> str: 9 | return ( 10 | f"{self.__class__.__name__}({', '.join([f'{k}={v}' for k, v in self.dict().items()])})" 11 | ) 12 | -------------------------------------------------------------------------------- /project/monitor/web/hooks/use-debounce.ts: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react'; 2 | 3 | export function useDebounce(value: T, delay: number): T { 4 | const [debouncedValue, setDebouncedValue] = useState(value); 5 | 6 | useEffect(() => { 7 | const handler = setTimeout(() => { 8 | setDebouncedValue(value); 9 | }, delay); 10 | 11 | return () => { 12 | clearTimeout(handler); 13 | }; 14 | }, [value, delay]); 15 | 16 | return debouncedValue; 17 | } 18 | -------------------------------------------------------------------------------- /lib/neurondb/neurondb/schemas/indices.py: -------------------------------------------------------------------------------- 1 | from neurondb.schemas.tables import SQLANeuronDescription 2 | from sqlalchemy import Index 3 | 4 | DB_INDICES = [ 5 | Index( 6 | f"{SQLANeuronDescription.__tablename__}_hnsw_cosine_index", 7 | SQLANeuronDescription.description_embedding, 8 | postgresql_using="hnsw", 9 | postgresql_with={"m": 32, "ef_construction": 200}, 10 | postgresql_ops={SQLANeuronDescription.description_embedding.name: "vector_cosine_ops"}, 11 | ), 12 | ] 13 | -------------------------------------------------------------------------------- /lib/neurondb/Fresh.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM postgres:16 2 | 3 | # Install pgvector extension 4 | RUN apt-get update \ 5 | && apt-get install -y postgresql-16-pgvector \ 6 | && apt-get clean \ 7 | && rm -rf /var/lib/apt/lists/* 8 | 9 | # Set environment variables 10 | ENV POSTGRES_PASSWORD=sysadmin 11 | ENV POSTGRES_USER=clarity 12 | ENV POSTGRES_DB=neurons 13 | ENV PGDATA=/var/lib/postgresql/data 14 | 15 | # Expose PostgreSQL port 16 | EXPOSE 5432 17 | 18 | # Set the default command to run PostgreSQL 19 | CMD ["postgres"] 20 | -------------------------------------------------------------------------------- /project/monitor/web/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "app/globals.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils", 16 | "ui": "@/components/ui", 17 | "lib": "@/lib", 18 | "hooks": "@/hooks" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /project/monitor/web/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /lib/neurondb/neurondb/schemas/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = [ 2 | "SQLABase", 3 | "DB_INDICES", 4 | "SQLALanguageModel", 5 | "SQLANeuron", 6 | "SQLANeuronDescription", 7 | "SQLANeuronExemplar", 8 | "SQLANeuronQuantiles", 9 | "get_sqla_neuron_id", 10 | ] 11 | 12 | from neurondb.schemas.base import SQLABase 13 | from neurondb.schemas.indices import DB_INDICES 14 | from neurondb.schemas.tables import ( 15 | SQLALanguageModel, 16 | SQLANeuron, 17 | SQLANeuronDescription, 18 | SQLANeuronExemplar, 19 | SQLANeuronQuantiles, 20 | get_sqla_neuron_id, 21 | ) 22 | -------------------------------------------------------------------------------- /lib/lucepkg/scripts/nb_kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get the directory of this script 4 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" 5 | cd $SCRIPT_DIR 6 | 7 | # Source shellenv to get the clr command 8 | . shellenv.sh 9 | 10 | # Check if at least one package name is provided 11 | if [ $# -eq 0 ]; then 12 | echo "Usage: $0 [package2] [package3] ..." 13 | exit 1 14 | fi 15 | 16 | # Register each package's kernel 17 | for pkg in "$@"; do 18 | clr activate $pkg 19 | .venv/bin/python -m ipykernel install --user --name=$pkg --display-name "TL Remote: $pkg" 20 | done 21 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "luce" 3 | version = "0.0.1" 4 | description = "The base environment for the Transluce Observability repository." 5 | 6 | requires-python = ">=3.9,<=3.12" 7 | dependencies = [ 8 | "pre-commit>=3.8.0", 9 | "jupyter>=1.1.1", 10 | "jupyter-collaboration>=1.2.0", 11 | "autoflake==2.3.1", 12 | ] 13 | 14 | [build-system] 15 | requires = ["hatchling"] 16 | build-backend = "hatchling.build" 17 | 18 | [tool.black] 19 | line-length = 100 20 | target-version = ['py310'] 21 | 22 | [tool.isort] 23 | profile = "black" 24 | line_length = 100 25 | 26 | [tool.uv] 27 | package = false 28 | -------------------------------------------------------------------------------- /project/monitor/web/public/vercel.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/activations/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "activations" 3 | version = "0.0.1" 4 | description = "Neuron activations" 5 | 6 | requires-python = "==3.12.*" 7 | dependencies = [ 8 | "util", 9 | "baukit @ git+https://github.com/choidami/baukit.git", 10 | ] 11 | 12 | [tool.uv.sources] 13 | util = {path = "../util", editable = true} 14 | 15 | [build-system] 16 | requires = ["hatchling"] 17 | build-backend = "hatchling.build" 18 | 19 | [tool.hatch.build.targets.wheel] 20 | packages = ["activations"] 21 | 22 | [tool.pyright] 23 | strict = ["activations"] 24 | reportMissingTypeStubs = false 25 | 26 | [tool.hatch.metadata] 27 | allow-direct-references = true 28 | -------------------------------------------------------------------------------- /lib/util/util/types.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Literal, NamedTuple, TypedDict 2 | 3 | import numpy as np 4 | import torch 5 | from numpy.typing import NDArray 6 | 7 | NDFloatArray = NDArray[np.floating[Any]] 8 | NDIntArray = NDArray[np.integer[Any]] 9 | 10 | 11 | class ChatMessage(TypedDict): 12 | role: Literal["user", "assistant", "system"] 13 | content: str 14 | 15 | 16 | class GenerateOutput(NamedTuple): 17 | output_ids_BT: NDIntArray 18 | logits_BV: torch.Tensor 19 | tokenwise_log_probs: list[tuple[NDIntArray, NDFloatArray]] 20 | continuations: list[str] 21 | 22 | 23 | class TopKResult(NamedTuple): 24 | indices: list[int] 25 | probs: list[float] 26 | -------------------------------------------------------------------------------- /project/monitor/web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["dom", "dom.iterable", "esnext"], 4 | "allowJs": true, 5 | "skipLibCheck": true, 6 | "strict": true, 7 | "noEmit": true, 8 | "esModuleInterop": true, 9 | "module": "esnext", 10 | "moduleResolution": "bundler", 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "jsx": "preserve", 14 | "incremental": true, 15 | "plugins": [ 16 | { 17 | "name": "next" 18 | } 19 | ], 20 | "paths": { 21 | "@/*": ["./*"] 22 | } 23 | }, 24 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 25 | "exclude": ["node_modules"] 26 | } 27 | -------------------------------------------------------------------------------- /lib/investigator/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "investigator" 3 | version = "0.0.1" 4 | description = "Tools comprising the Investigator which helps process large amounts of data" 5 | 6 | requires-python = "==3.12.*" 7 | dependencies = [ 8 | "util", 9 | "neurondb", 10 | ] 11 | 12 | [tool.uv.sources] 13 | util = {path = "../util", editable = true} 14 | neurondb = {path = "../neurondb", editable = true} 15 | 16 | [build-system] 17 | requires = ["hatchling"] 18 | build-backend = "hatchling.build" 19 | 20 | [tool.hatch.build.targets.wheel] 21 | packages = ["investigator"] 22 | 23 | [tool.pyright] 24 | strict = ["investigator"] 25 | reportMissingTypeStubs = false 26 | 27 | [tool.hatch.metadata] 28 | allow-direct-references = true 29 | -------------------------------------------------------------------------------- /project/monitor/web/app/store/api/sessionApi.ts: -------------------------------------------------------------------------------- 1 | import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; 2 | import { BASE_URL } from '@/app/constants'; 3 | 4 | interface FetchNeuronsParams { 5 | sessionId: string; 6 | activationQuantileThreshold: string; 7 | } 8 | 9 | export const sessionApi = createApi({ 10 | reducerPath: 'sessionApi', 11 | baseQuery: fetchBaseQuery({ baseUrl: BASE_URL }), // Adjust the base URL as needed 12 | endpoints: (builder) => ({ 13 | fetchSession: builder.query< 14 | string, 15 | void 16 | >({ 17 | query: () => ({ 18 | url: `register`, 19 | method: 'POST', 20 | }), 21 | }), 22 | }), 23 | }); 24 | 25 | export const { useFetchSessionQuery } = sessionApi; 26 | -------------------------------------------------------------------------------- /lib/neurondb/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "neurondb" 3 | version = "0.0.1" 4 | description = "Neuron database" 5 | 6 | requires-python = "==3.12.*" 7 | dependencies = [ 8 | "sqlalchemy==2.0.32", 9 | "pgvector==0.3.2", 10 | "psycopg2-binary==2.9.9", 11 | "util", 12 | "activations", 13 | ] 14 | 15 | [tool.uv.sources] 16 | util = {path = "../util", editable = true} 17 | activations = {path = "../activations", editable = true} 18 | 19 | [build-system] 20 | requires = ["hatchling"] 21 | build-backend = "hatchling.build" 22 | 23 | [tool.hatch.build.targets.wheel] 24 | packages = ["neurondb"] 25 | 26 | [tool.pyright] 27 | strict = ["neurondb"] 28 | reportMissingTypeStubs = false 29 | 30 | [tool.hatch.metadata] 31 | allow-direct-references = true 32 | -------------------------------------------------------------------------------- /lib/util/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "util" 7 | version = "0.0.1" 8 | description = "Utility library" 9 | 10 | requires-python = "==3.12.*" 11 | dependencies = [ 12 | "backoff==2.2.1", 13 | "datasets==2.20.0", 14 | "matplotlib==3.9.0", 15 | "nnsight==0.3.3", 16 | "numpy==1.26.4", 17 | "openai==1.45.0", 18 | "anthropic==0.34.1", 19 | "orjson==3.10.6", 20 | "scikit-learn==1.5.0", 21 | "tiktoken==0.7.0", 22 | "torch==2.4.0", 23 | "transformers==4.45.0", 24 | "python-dotenv==1.0.1", 25 | ] 26 | 27 | [tool.hatch.build.targets.wheel] 28 | packages = ["util"] 29 | 30 | [tool.pyright] 31 | strict = ["util"] 32 | reportMissingTypeStubs = false 33 | 34 | [tool.hatch.metadata] 35 | allow-direct-references = true 36 | -------------------------------------------------------------------------------- /project/monitor/scripts/web.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Navigate to the parent directory of this script 5 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )" 6 | cd $SCRIPT_DIR 7 | 8 | # Default values 9 | PORT=3000 10 | HOST="http://localhost:8888" 11 | 12 | # Parse arguments 13 | while [[ "$#" -gt 0 ]]; do 14 | case $1 in 15 | --port|-p) PORT="$2"; shift ;; 16 | --host|-h) HOST="$2"; shift ;; 17 | *) echo "Unknown parameter passed: $1"; exit 1 ;; 18 | esac 19 | shift 20 | done 21 | 22 | # Check if node_modules exists and run npm install if needed 23 | cd web 24 | if [ ! -d "node_modules" ]; then 25 | echo "Installing dependencies..." 26 | npm install 27 | fi 28 | 29 | # Run Next.js with environment variables 30 | NEXT_PUBLIC_API_HOST=$HOST npm run dev -- --port $PORT 31 | -------------------------------------------------------------------------------- /project/expgen/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "expgen" 3 | version = "0.0.1" 4 | description = "explanation generation and scoring pipeline" 5 | 6 | requires-python = "==3.12.*" 7 | dependencies = [ 8 | "util", 9 | "activations", 10 | "explanations", 11 | "jupyter>=1.0.0", 12 | "statsmodels>=0.14.0", 13 | ] 14 | 15 | [tool.uv.sources] 16 | util = {path = "../../lib/util", editable = true} 17 | activations = {path = "../../lib/activations", editable = true} 18 | explanations = {path = "../../lib/explanations", editable = true} 19 | 20 | [build-system] 21 | requires = ["hatchling"] 22 | build-backend = "hatchling.build" 23 | 24 | [tool.hatch.build.targets.wheel] 25 | packages = ["expgen"] 26 | 27 | [tool.pyright] 28 | # strict = ["expgen"] 29 | reportMissingTypeStubs = false 30 | 31 | [tool.hatch.metadata] 32 | allow-direct-references = true 33 | -------------------------------------------------------------------------------- /project/monitor/web/components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as LabelPrimitive from "@radix-ui/react-label" 5 | import { cva, type VariantProps } from "class-variance-authority" 6 | 7 | import { cn } from "@/lib/utils" 8 | 9 | const labelVariants = cva( 10 | "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" 11 | ) 12 | 13 | const Label = React.forwardRef< 14 | React.ElementRef, 15 | React.ComponentPropsWithoutRef & 16 | VariantProps 17 | >(({ className, ...props }, ref) => ( 18 | 23 | )) 24 | Label.displayName = LabelPrimitive.Root.displayName 25 | 26 | export { Label } 27 | -------------------------------------------------------------------------------- /project/monitor/web/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | export interface TextareaProps 6 | extends React.TextareaHTMLAttributes {} 7 | 8 | const Textarea = React.forwardRef( 9 | ({ className, ...props }, ref) => { 10 | return ( 11 |