Skip to content

Commit 75fc08a

Browse files
author
Andrei Bratu
authored
Merge pull request #8 from humanloop/ENG-1430-eval-run
Parity with Python SDK: File utilities + evaluation utility
2 parents b796d2b + 385002c commit 75fc08a

32 files changed

+7486
-665
lines changed

.fernignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
11
# Specify files that shouldn't be modified by Fern
2+
3+
# Custom code
4+
5+
src/otel
6+
src/eval_utils
7+
src/utilities
8+
src/index.ts
9+
src/humanloop.client.ts
10+
11+
# Tests
12+
13+
tests
14+
15+
# CI Action
16+
17+
.github/workflows/ci.yml
18+
19+
# Config files
20+
21+
.prettierrc.yml
22+
babel.config.js
23+
jest.config.js
24+
25+
# Package Scripts
26+
27+
scripts

.github/workflows/ci.yml

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,59 @@ name: ci
33
on: [push]
44

55
jobs:
6-
compile:
7-
runs-on: ubuntu-latest
8-
9-
steps:
10-
- name: Checkout repo
11-
uses: actions/checkout@v3
12-
13-
- name: Set up node
14-
uses: actions/setup-node@v3
15-
16-
- name: Compile
17-
run: yarn && yarn build
18-
19-
test:
20-
runs-on: ubuntu-latest
21-
22-
steps:
23-
- name: Checkout repo
24-
uses: actions/checkout@v3
25-
26-
- name: Set up node
27-
uses: actions/setup-node@v3
28-
29-
- name: Compile
30-
run: yarn && yarn test
31-
32-
publish:
33-
needs: [ compile, test ]
34-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
35-
runs-on: ubuntu-latest
36-
steps:
37-
- name: Checkout repo
38-
uses: actions/checkout@v3
39-
- name: Set up node
40-
uses: actions/setup-node@v3
41-
- name: Install dependencies
42-
run: yarn install
43-
- name: Build
44-
run: yarn build
45-
46-
- name: Publish to npm
47-
run: |
48-
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
49-
if [[ ${GITHUB_REF} == *alpha* ]]; then
50-
npm publish --access public --tag alpha
51-
elif [[ ${GITHUB_REF} == *beta* ]]; then
52-
npm publish --access public --tag beta
53-
else
54-
npm publish --access public
55-
fi
56-
env:
57-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6+
compile:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repo
11+
uses: actions/checkout@v3
12+
13+
- name: Set up node
14+
uses: actions/setup-node@v3
15+
16+
- name: Compile
17+
run: yarn && yarn build
18+
19+
test:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
26+
- name: Set up node
27+
uses: actions/setup-node@v3
28+
29+
- name: Compile
30+
run: yarn && yarn test
31+
env:
32+
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
33+
ANTHROPIC_KEY: ${{ secrets.ANTHROPIC_KEY }}
34+
COHERE_KEY: ${{ secrets.COHERE_KEY }}
35+
36+
publish:
37+
needs: [compile, test]
38+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout repo
42+
uses: actions/checkout@v3
43+
- name: Set up node
44+
uses: actions/setup-node@v3
45+
- name: Install dependencies
46+
run: yarn install
47+
- name: Build
48+
run: yarn build
49+
50+
- name: Publish to npm
51+
run: |
52+
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
53+
if [[ ${GITHUB_REF} == *alpha* ]]; then
54+
npm publish --access public --tag alpha
55+
elif [[ ${GITHUB_REF} == *beta* ]]; then
56+
npm publish --access public --tag beta
57+
else
58+
npm publish --access public
59+
fi
60+
env:
61+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
.DS_Store
3-
/dist
3+
/dist
4+
.env

.prettierignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Ignore Fern auto-generated files
2+
3+
src/Client.ts
4+
src/api
5+
src/core
6+
src/errors
7+
src/serialization
8+
src/environment.ts
9+
src/version.ts
10+
11+
tests/custom.test.ts
12+
tests/unit
13+
14+
jest.config.js
15+
package.json
16+
yarn.lock
17+
tsconfig.json

.prettierrc.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
tabWidth: 4
2-
printWidth: 120
2+
printWidth: 88
3+
semi: true
4+
importOrderSeparation: true
5+
importOrderSortSpecifiers: true
6+
importOrderGroupNamespaceSpecifiers: true
7+
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]
8+
trailingComma: "all"
9+
plugins:
10+
- "@trivago/prettier-plugin-sort-imports"

babel.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
"@babel/preset-env",
5+
{ targets: { node: "current" } }
6+
],
7+
],
8+
plugins: [
9+
"@babel/plugin-transform-modules-commonjs"
10+
]
11+
};

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22
module.exports = {
33
preset: "ts-jest",
44
testEnvironment: "node",
5+
// If Jest complains about an unknown symbol when running tests, you're dealing with dependency
6+
// written in ES module instead of CJS format. Add the dependency in the exclusive regex group below.
7+
// All modules NOT matching the pattern (thus exclusive grouping) will be passed to babel for
8+
// transpilation before tests are ran.
9+
transformIgnorePatterns: ["<rootDir>/node_modules/(?!p-map/)"],
10+
transform: {
11+
"\\.js$": "babel-jest"
12+
}
513
};

package.json

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,62 @@
88
"scripts": {
99
"format": "prettier . --write --ignore-unknown",
1010
"build": "tsc",
11-
"prepack": "cp -rv dist/. .",
12-
"test": "jest"
11+
"prepack": "yarn build && ./scripts/prepack.sh",
12+
"clean": "./scripts/clean.sh",
13+
"test": "jest --detectOpenHandles --forceExit"
1314
},
1415
"dependencies": {
15-
"url-join": "4.0.1",
16+
"@opentelemetry/api": "^1.9.0",
17+
"@opentelemetry/auto-instrumentations-node": "^0.53.0",
18+
"@opentelemetry/sdk-metrics": "^1.28.0",
19+
"@opentelemetry/sdk-node": "^0.55.0",
20+
"@opentelemetry/sdk-trace-node": "^1.28.0",
21+
"@traceloop/ai-semantic-conventions": "^0.11.0",
22+
"@traceloop/instrumentation-anthropic": "^0.11.1",
23+
"@traceloop/instrumentation-cohere": "^0.11.1",
24+
"@traceloop/instrumentation-openai": "^0.11.3",
25+
"cli-progress": "^3.12.0",
1626
"form-data": "^4.0.0",
27+
"form-data-encoder": "^4.0.2",
1728
"formdata-node": "^6.0.3",
29+
"lodash": "^4.17.21",
30+
"nanoid": "^5.0.9",
1831
"node-fetch": "2.7.0",
32+
"p-map": "^7.0.3",
1933
"qs": "6.11.2",
2034
"readable-stream": "^4.5.2",
21-
"form-data-encoder": "^4.0.2"
35+
"stable-hash": "^0.0.4",
36+
"ts-json-schema-generator": "^2.3.0",
37+
"url-join": "4.0.1",
38+
"uuid": "^11.0.3"
2239
},
2340
"devDependencies": {
24-
"@types/url-join": "4.0.1",
25-
"@types/qs": "6.9.8",
41+
"@anthropic-ai/sdk": "^0.32.1",
42+
"@babel/core": "^7.26.0",
43+
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
44+
"@babel/preset-env": "^7.26.0",
45+
"@trivago/prettier-plugin-sort-imports": "^5.2.0",
46+
"@types/cli-progress": "^3.11.6",
47+
"@types/jest": "29.5.5",
48+
"@types/lodash": "4.17.5",
49+
"@types/node": "17.0.33",
2650
"@types/node-fetch": "2.6.9",
51+
"@types/qs": "6.9.8",
2752
"@types/readable-stream": "^4.0.15",
53+
"@types/url-join": "4.0.1",
54+
"babel-jest": "^29.7.0",
55+
"cohere-ai": "^7.15.0",
56+
"dotenv": "^16.4.6",
2857
"fetch-mock-jest": "^1.5.1",
29-
"webpack": "^5.94.0",
30-
"ts-loader": "^9.3.1",
3158
"jest": "29.7.0",
32-
"@types/jest": "29.5.5",
33-
"ts-jest": "29.1.1",
3459
"jest-environment-jsdom": "29.7.0",
35-
"@types/node": "17.0.33",
36-
"prettier": "2.7.1",
37-
"typescript": "4.6.4"
60+
"jsonschema": "^1.4.1",
61+
"openai": "^4.74.0",
62+
"prettier": "^3.4.2",
63+
"ts-jest": "29.1.1",
64+
"ts-loader": "^9.3.1",
65+
"typescript": "4.6.4",
66+
"webpack": "^5.94.0"
3867
},
3968
"browser": {
4069
"fs": false,

scripts/clean.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cat .yalc.clean | xargs rm -rf;
3+
rm -f .yalc.clean;

scripts/prepack.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
if npm list --global | grep -q yalc; then
3+
# Local dev environment
4+
cp -rv dist/. . | awk '{print $3}' | tail -n +2 | cut -c 3- > .yalc.clean;
5+
echo .yalc.clean >> .yalc.clean;
6+
else
7+
# CI environment, releasing the package
8+
cp -rv dist/. .;
9+
fi
10+

0 commit comments

Comments
 (0)