Skip to content

Commit

Permalink
Replace duplicated definitions with @braintrust/core. (#37)
Browse files Browse the repository at this point in the history
We have factored out the shared deps between autoevals and sdk to the
`@braintrust/core` (JS) / `braintrust_core` (PY) packages, so we can
replace the redundant definitions in autoevals with imports from these
new packages.
  • Loading branch information
manugoyal authored Dec 6, 2023
1 parent 85384e5 commit e5f733b
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 134 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repos:
rev: v0.0.282
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
hooks:
Expand Down
15 changes: 0 additions & 15 deletions js/base.ts

This file was deleted.

2 changes: 1 addition & 1 deletion js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @module autoevals
*/

export * from "./base.js";
export { Score, ScorerArgs, Scorer } from "@braintrust/core";
export * from "./llm.js";
export * from "./string.js";
export * from "./number.js";
Expand Down
2 changes: 1 addition & 1 deletion js/json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scorer } from "./base.js";
import { Scorer } from "@braintrust/core";
import { NumericDiff } from "./number.js";
import { LevenshteinScorer } from "./string.js";

Expand Down
2 changes: 1 addition & 1 deletion js/llm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as yaml from "js-yaml";
import mustache from "mustache";

import { Score, Scorer, ScorerArgs } from "./base.js";
import { Score, Scorer, ScorerArgs } from "@braintrust/core";
import { ChatCache, cachedChatCompletion } from "./oai.js";
import { templates } from "./templates.js";
import {
Expand Down
2 changes: 1 addition & 1 deletion js/number.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scorer } from "./base.js";
import { Scorer } from "@braintrust/core";

/**
* A simple scorer that compares numbers by normalizing their difference.
Expand Down
2 changes: 1 addition & 1 deletion js/string.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scorer } from "./base.js";
import { Scorer } from "@braintrust/core";
import levenshtein from "js-levenshtein";

/**
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"watch": "tsc --watch",
"docs": "npx typedoc --options typedoc.json js/index.ts",
"test": "jest",
"prepublishOnly": "./scripts/node_prepublish.py",
"postpublish": "./scripts/node_postpublish.py"
"prepublishOnly": "../../scripts/node_prepublish_autoevals.py",
"postpublish": "../../scripts/node_postpublish_autoevals.py"
},
"author": "",
"license": "MIT",
Expand All @@ -45,6 +45,7 @@
"typescript": "^5.1.6"
},
"dependencies": {
"@braintrust/core": "^0.0.6",
"@types/node": "^20.4.4",
"esbuild": "^0.19.1",
"js-levenshtein": "^1.1.6",
Expand Down
3 changes: 2 additions & 1 deletion py/autoevals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"""

from .base import *
from braintrust_core.score import Score, Scorer

from .json import *
from .llm import *
from .number import *
Expand Down
55 changes: 0 additions & 55 deletions py/autoevals/base.py

This file was deleted.

3 changes: 2 additions & 1 deletion py/autoevals/json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json

from .base import Score, Scorer
from braintrust_core.score import Score, Scorer

from .number import NumericDiff
from .string import Levenshtein

Expand Down
2 changes: 1 addition & 1 deletion py/autoevals/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import chevron
import yaml
from braintrust_core.score import Score, Scorer

from .base import Score, Scorer
from .oai import arun_cached_request, run_cached_request

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
Expand Down
2 changes: 1 addition & 1 deletion py/autoevals/number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import Score, Scorer
from braintrust_core.score import Score, Scorer


class NumericDiff(Scorer):
Expand Down
5 changes: 1 addition & 4 deletions py/autoevals/string.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from braintrust_core.score import Score, Scorer
from Levenshtein import distance

from autoevals.base import Score

from .base import Score, Scorer


class Levenshtein(Scorer):
"""
Expand Down
13 changes: 0 additions & 13 deletions py/autoevals/util.py

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/node_postpublish.py

This file was deleted.

24 changes: 0 additions & 24 deletions scripts/node_prepublish.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
with open(os.path.join(dir_name, "README.md"), "r", encoding="utf-8") as f:
long_description = f.read()

install_requires = ["chevron", "levenshtein", "pyyaml"]
install_requires = ["chevron", "levenshtein", "pyyaml", "braintrust_core"]

extras_require = {
"dev": [
Expand Down

0 comments on commit e5f733b

Please sign in to comment.