Skip to content

Commit

Permalink
Move sample application to new examples/apps repo dir
Browse files Browse the repository at this point in the history
  • Loading branch information
cephalization committed Dec 19, 2024
1 parent a414348 commit b8f1147
Show file tree
Hide file tree
Showing 10 changed files with 1,408 additions and 17 deletions.
10 changes: 6 additions & 4 deletions js/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Typescript packages for interfacing with Phoenix and evaluating LLM applications

Provides a client and utilities for interacting with the phoenix application.

### [phoenix-evals](./packages/phoenix-evals/)
## Examples

A library for evaluating LLM applications.
### [notebooks](./examples/notebooks/)

### [phoenix-types](./packages/phoenix-types/)
A collection of Deno Jupyter notebooks that demonstrate how to interact with Phoenix using JavaScript.

A common set of types and interfaces used by Phoenix typescript packages.
### [phoenix-experiment-runner](./examples/apps/phoenix-experiment-runner/)

An example app that uses the phoenix-client and @clack/prompts to run experiments interactively.
43 changes: 43 additions & 0 deletions js/examples/apps/phoenix-experiment-runner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Phoenix Experiment Runner

This is an example app that uses the phoenix-client and @clack/prompts to run experiments.

It runs against the `llama3.2` model, pointing to a local ollama instance.

## Setup

### Requirements

- [Phoenix](https://phoenix.arize.com/) running locally on `http://localhost:6006`
- `pnpm d:up` will start Phoenix
- [Ollama](https://ollama.com/) with `llama3.2` installed
- Node.js 20+
- pnpm

### Install dependencies

```bash
pnpm install
pnpm -r build
```

This will build all the dependencies in the monorepo and the app.

### Run the app

```bash
pnpm d:up
pnpm dev
```

This will start Phoenix at `http://localhost:6006` and the app in watch mode.

### Build the app

```bash
pnpm d:up
pnpm build
pnpm start
```

This will start Phoenix and build the app, then run the app.
6 changes: 6 additions & 0 deletions js/examples/apps/phoenix-experiment-runner/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
phoenix:
image: arizephoenix/phoenix:latest
ports:
- "6006:6006" # UI and OTLP HTTP collector
- "4317:4317" # OTLP gRPC collector
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
asEvaluator,
createClient,
runExperiment,
RunExperimentParams,
} from "../src";
type RunExperimentParams,
} from "@arizeai/phoenix-client";
import { intro, outro, select, spinner, log, confirm } from "@clack/prompts";
import { Factuality, Humor } from "autoevals";

Expand All @@ -26,13 +26,27 @@ const getDatasets = () =>

const main = async () => {
intro("Phoenix Experiment Runner");
const datasets = await getDatasets();
let datasets: Awaited<ReturnType<typeof getDatasets>> = [];
try {
datasets = await getDatasets();
} catch (e) {
if (e instanceof Error && e.message === "fetch failed") {
log.error(
"Cannot connect to Phoenix at http://localhost:6006! Start it with `pnpm d:up` and try again!"
);
return;
}
log.error(String(e));
return;
}

if (datasets.length === 0) {
outro(
"No datasets found in your Phoenix instance. Please create a dataset first!"
"No datasets found in your Phoenix instance. Please create a dataset at http://localhost:6006/datasets first!"
);
return;
}

const datasetId = await select({
message: "Select a dataset",
options: datasets.map((dataset) => ({
Expand Down
29 changes: 29 additions & 0 deletions js/examples/apps/phoenix-experiment-runner/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "phoenix-experiment-runner",
"version": "1.0.0",
"description": "An example app that uses the phoenix-client to run experiments",
"main": "dist/index.js",
"type": "module",
"private": true,
"dependencies": {
"@arizeai/phoenix-client": "workspace:*",
"@clack/prompts": "^0.8.2",
"autoevals": "^0.0.111"
},
"scripts": {
"start": "node dist/index.js",
"d:up": "docker compose up -d",
"d:down": "docker compose down",
"build": "tsc",
"dev": "tsx watch index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^20.14.11",
"rimraf": "^5.0.10",
"tsx": "^4.19.1",
"typescript": "^5.7.2"
}
}
26 changes: 26 additions & 0 deletions js/examples/apps/phoenix-experiment-runner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"verbatimModuleSyntax": true,

/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,

/* If transpiling with TypeScript: */
"module": "NodeNext",
"outDir": "dist",
"sourceMap": true,

/* If your code doesn't run in the DOM: */
"lib": ["es2022"]
}
}
4 changes: 1 addition & 3 deletions js/packages/phoenix-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"clean": "rimraf dist",
"prebuild": "pnpm run clean && pnpm run generate",
"generate": "openapi-typescript ../../../schemas/openapi.json -o ./src/__generated__/api/v1.d.ts",
"generate": "openapi-typescript ../../../schemas/openapi.json -o ./src/__generated__/api/v1.ts",
"build": "tsc --build tsconfig.json tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test dist/examples",
"type:check": "tsc --noEmit",
Expand All @@ -29,9 +29,7 @@
"author": "",
"license": "ELv2",
"devDependencies": {
"@clack/prompts": "^0.8.2",
"@types/node": "^20.14.11",
"autoevals": "^0.0.111",
"openapi-typescript": "^7.4.1",
"tsx": "^4.19.1"
},
Expand Down
Loading

0 comments on commit b8f1147

Please sign in to comment.