Skip to content

Commit

Permalink
Merge branch 'main' into brace/expose-client-args
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored Aug 20, 2024
2 parents d8cd615 + bee2a0c commit 5f89d43
Show file tree
Hide file tree
Showing 111 changed files with 11,935 additions and 1,978 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install dependencies
run: |
poetry install --with dev
poetry run pip install -U langchain
poetry run pip install -U langchain langchain_anthropic langchain_openai rapidfuzz
- name: Run Python integration tests
uses: ./.github/actions/python-integration-tests
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/js_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18.x, 19.x, 20.x, 21.x, 22.x]
node-version: [18.x, 20.x, "22.4.1"]
# See Node.js release schedule at https://nodejs.org/en/about/releases/
include:
- os: windows-latest
Expand All @@ -107,4 +107,4 @@ jobs:
- name: Check version
run: yarn run check-version
- name: Test
run: yarn run test
run: yarn run test
4 changes: 3 additions & 1 deletion .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
defaults:
Expand All @@ -42,7 +44,7 @@ jobs:
- name: Install dependencies
run: |
poetry install --with dev,lint
poetry run pip install -U langchain
poetry run pip install -U langchain langchain-core langchain_anthropic langchain_openai
- name: Build ${{ matrix.python-version }}
run: poetry build
- name: Lint ${{ matrix.python-version }}
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/release_js.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: JS Release

on:
push:
branches:
- main
paths:
- "js/package.json"
workflow_dispatch:

jobs:
Expand All @@ -11,33 +16,34 @@ jobs:
permissions:
contents: write
id-token: write
defaults:
run:
working-directory: "js"
steps:
- uses: actions/checkout@v3
# JS Build
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 20.x
cache: "yarn"
cache-dependency-path: "js/yarn.lock"
- name: Install dependencies
run: cd js && yarn install --immutable
run: yarn install --immutable
- name: Build
run: cd js && yarn run build
run: yarn run build
- name: Check version
run: cd js && yarn run check-version
run: yarn run check-version
- name: Check NPM version
id: check_npm_version
run: |
cd js
if yarn run check-npm-version; then
echo "::set-output name=should_publish::true"
echo "should_publish=true" >> $GITHUB_OUTPUT
else
echo "::set-output name=should_publish::false"
echo "should_publish=false" >> $GITHUB_OUTPUT
fi
- name: Publish package to NPM
if: steps.check_npm_version.outputs.should_publish == 'true'
run: |
cd js
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
yarn publish --non-interactive
18 changes: 12 additions & 6 deletions _scripts/_fetch_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fetch and prune the Langsmith spec."""

import argparse
from pathlib import Path

Expand All @@ -19,7 +20,9 @@ def process_schema(sub_schema):
get_dependencies(schema, sub_schema["$ref"].split("/")[-1], new_components)
else:
if "items" in sub_schema and "$ref" in sub_schema["items"]:
get_dependencies(schema, sub_schema["items"]["$ref"].split("/")[-1], new_components)
get_dependencies(
schema, sub_schema["items"]["$ref"].split("/")[-1], new_components
)
for keyword in ["anyOf", "oneOf", "allOf"]:
if keyword in sub_schema:
for item in sub_schema[keyword]:
Expand All @@ -38,8 +41,6 @@ def process_schema(sub_schema):
process_schema(item)




def _extract_langsmith_routes_and_properties(schema, operation_ids):
new_paths = {}
new_components = {"schemas": {}}
Expand Down Expand Up @@ -98,20 +99,25 @@ def test_openapi_specification(spec: dict):
assert errors is None, f"OpenAPI validation failed: {errors}"


def main(out_file: str = "openapi.yaml", url: str = "https://web.smith.langchain.com/openapi.json"):
def main(
out_file: str = "openapi.yaml",
url: str = "https://web.smith.langchain.com/openapi.json",
):
langsmith_schema = get_langsmith_runs_schema(url=url)
parent_dir = Path(__file__).parent.parent
test_openapi_specification(langsmith_schema)
with (parent_dir / "openapi" / out_file).open("w") as f:
# Sort the schema keys so the openapi version and info come at the top
for key in ['openapi', 'info', 'paths', 'components']:
for key in ["openapi", "info", "paths", "components"]:
langsmith_schema[key] = langsmith_schema.pop(key)
f.write(yaml.dump(langsmith_schema, sort_keys=False))


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--url", type=str, default="https://web.smith.langchain.com/openapi.json")
parser.add_argument(
"--url", type=str, default="https://web.smith.langchain.com/openapi.json"
)
parser.add_argument("--output", type=str, default="openapi.yaml")
args = parser.parse_args()
main(args.output, url=args.url)
1 change: 1 addition & 0 deletions js/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
ignorePatterns: [
".eslintrc.cjs",
"scripts",
"src/utils/lodash/*",
"node_modules",
"dist",
"dist-cjs",
Expand Down
20 changes: 20 additions & 0 deletions js/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,38 @@ Chinook_Sqlite.sql
/evaluation.js
/evaluation.d.ts
/evaluation.d.cts
/evaluation/langchain.cjs
/evaluation/langchain.js
/evaluation/langchain.d.ts
/evaluation/langchain.d.cts
/schemas.cjs
/schemas.js
/schemas.d.ts
/schemas.d.cts
/langchain.cjs
/langchain.js
/langchain.d.ts
/langchain.d.cts
/wrappers.cjs
/wrappers.js
/wrappers.d.ts
/wrappers.d.cts
/anonymizer.cjs
/anonymizer.js
/anonymizer.d.ts
/anonymizer.d.cts
/wrappers/openai.cjs
/wrappers/openai.js
/wrappers/openai.d.ts
/wrappers/openai.d.cts
/wrappers/vercel.cjs
/wrappers/vercel.js
/wrappers/vercel.d.ts
/wrappers/vercel.d.cts
/singletons/traceable.cjs
/singletons/traceable.js
/singletons/traceable.d.ts
/singletons/traceable.d.cts
/index.cjs
/index.js
/index.d.ts
Expand Down
1 change: 1 addition & 0 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Tracing can be activated by setting the following environment variables or by ma
```typescript
process.env["LANGSMITH_TRACING"] = "true";
process.env["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com";
// process.env["LANGCHAIN_ENDPOINT"] = "https://eu.api.smith.langchain.com"; // If signed up in the EU region
process.env["LANGCHAIN_API_KEY"] = "<YOUR-LANGSMITH-API-KEY>";
// process.env["LANGCHAIN_PROJECT"] = "My Project Name"; // Optional: "default" is used if not set
```
Expand Down
90 changes: 85 additions & 5 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.1.23",
"version": "0.1.42",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"packageManager": "[email protected]",
"files": [
Expand All @@ -21,18 +21,38 @@
"evaluation.js",
"evaluation.d.ts",
"evaluation.d.cts",
"evaluation/langchain.cjs",
"evaluation/langchain.js",
"evaluation/langchain.d.ts",
"evaluation/langchain.d.cts",
"schemas.cjs",
"schemas.js",
"schemas.d.ts",
"schemas.d.cts",
"langchain.cjs",
"langchain.js",
"langchain.d.ts",
"langchain.d.cts",
"wrappers.cjs",
"wrappers.js",
"wrappers.d.ts",
"wrappers.d.cts",
"anonymizer.cjs",
"anonymizer.js",
"anonymizer.d.ts",
"anonymizer.d.cts",
"wrappers/openai.cjs",
"wrappers/openai.js",
"wrappers/openai.d.ts",
"wrappers/openai.d.cts",
"wrappers/vercel.cjs",
"wrappers/vercel.js",
"wrappers/vercel.d.ts",
"wrappers/vercel.d.cts",
"singletons/traceable.cjs",
"singletons/traceable.js",
"singletons/traceable.d.ts",
"singletons/traceable.d.cts",
"index.cjs",
"index.js",
"index.d.ts",
Expand Down Expand Up @@ -81,17 +101,22 @@
"commander": "^10.0.1",
"p-queue": "^6.6.2",
"p-retry": "4",
"semver": "^7.6.3",
"uuid": "^9.0.0"
},
"devDependencies": {
"@ai-sdk/openai": "^0.0.40",
"@babel/preset-env": "^7.22.4",
"@faker-js/faker": "^8.4.1",
"@jest/globals": "^29.5.0",
"@langchain/core": "^0.1.32",
"@langchain/langgraph": "^0.0.8",
"@langchain/core": "^0.2.17",
"@langchain/langgraph": "^0.0.29",
"@langchain/openai": "^0.2.5",
"@tsconfig/recommended": "^1.0.2",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"ai": "^3.2.37",
"babel-jest": "^29.5.0",
"cross-env": "^7.0.3",
"dotenv": "^16.1.3",
Expand All @@ -101,18 +126,28 @@
"eslint-plugin-no-instanceof": "^1.0.1",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"langchain": "^0.2.10",
"openai": "^4.38.5",
"prettier": "^2.8.8",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"zod": "^3.23.8"
},
"peerDependencies": {
"@langchain/core": "*",
"langchain": "*",
"openai": "*"
},
"peerDependenciesMeta": {
"openai": {
"optional": true
},
"langchain": {
"optional": true
},
"@langchain/core": {
"optional": true
}
},
"lint-staged": {
Expand Down Expand Up @@ -167,6 +202,15 @@
"import": "./evaluation.js",
"require": "./evaluation.cjs"
},
"./evaluation/langchain": {
"types": {
"import": "./evaluation/langchain.d.ts",
"require": "./evaluation/langchain.d.cts",
"default": "./evaluation/langchain.d.ts"
},
"import": "./evaluation/langchain.js",
"require": "./evaluation/langchain.cjs"
},
"./schemas": {
"types": {
"import": "./schemas.d.ts",
Expand All @@ -176,6 +220,15 @@
"import": "./schemas.js",
"require": "./schemas.cjs"
},
"./langchain": {
"types": {
"import": "./langchain.d.ts",
"require": "./langchain.d.cts",
"default": "./langchain.d.ts"
},
"import": "./langchain.js",
"require": "./langchain.cjs"
},
"./wrappers": {
"types": {
"import": "./wrappers.d.ts",
Expand All @@ -185,6 +238,15 @@
"import": "./wrappers.js",
"require": "./wrappers.cjs"
},
"./anonymizer": {
"types": {
"import": "./anonymizer.d.ts",
"require": "./anonymizer.d.cts",
"default": "./anonymizer.d.ts"
},
"import": "./anonymizer.js",
"require": "./anonymizer.cjs"
},
"./wrappers/openai": {
"types": {
"import": "./wrappers/openai.d.ts",
Expand All @@ -194,6 +256,24 @@
"import": "./wrappers/openai.js",
"require": "./wrappers/openai.cjs"
},
"./wrappers/vercel": {
"types": {
"import": "./wrappers/vercel.d.ts",
"require": "./wrappers/vercel.d.cts",
"default": "./wrappers/vercel.d.ts"
},
"import": "./wrappers/vercel.js",
"require": "./wrappers/vercel.cjs"
},
"./singletons/traceable": {
"types": {
"import": "./singletons/traceable.d.ts",
"require": "./singletons/traceable.d.cts",
"default": "./singletons/traceable.d.ts"
},
"import": "./singletons/traceable.js",
"require": "./singletons/traceable.cjs"
},
"./package.json": "./package.json"
}
}
}
Loading

0 comments on commit 5f89d43

Please sign in to comment.