-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cohere[minor]: Fix token counts, add usage_metadata (#5732)
* cohere[minor]: Fix token counts, add usage_metadata * chore: lint files * remove skipped token usage tests from cohere standard int test * bump min core version to usage_metadata update * add streamUsage * added cohere to latest/lowest dep tests * conditionally run latest/lowest * nit * cr * cr * cr * revert * test * try just pr * cr * cr * only log files * more tests * toJson * use git to access changed files * fix if statements * fix test * unfocus jest tests and add eslint rule * add eslint-plugin-jest
- Loading branch information
1 parent
ac204f8
commit 75dd790
Showing
13 changed files
with
1,158 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
dependency_range_tests/scripts/with_standard_tests/cohere/node/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "dependency-range-tests", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "Tests dependency ranges for LangChain.", | ||
"dependencies": { | ||
"semver": "^7.5.4" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_lowest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const fs = require("fs"); | ||
const semver = require("semver"); | ||
|
||
const communityPackageJsonPath = "/app/monorepo/libs/langchain-cohere/package.json"; | ||
|
||
const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); | ||
|
||
if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { | ||
const minVersion = semver.minVersion( | ||
currentPackageJson.dependencies["@langchain/core"] | ||
).version; | ||
currentPackageJson.overrides = { | ||
...currentPackageJson.overrides, | ||
"@langchain/core": minVersion, | ||
}; | ||
currentPackageJson.dependencies = { | ||
...currentPackageJson.dependencies, | ||
"@langchain/core": minVersion, | ||
}; | ||
} | ||
|
||
fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); |
22 changes: 22 additions & 0 deletions
22
dependency_range_tests/scripts/with_standard_tests/cohere/node/yarn.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
lru-cache@^6.0.0: | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" | ||
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== | ||
dependencies: | ||
yallist "^4.0.0" | ||
|
||
semver@^7.5.4: | ||
version "7.5.4" | ||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" | ||
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== | ||
dependencies: | ||
lru-cache "^6.0.0" | ||
|
||
yallist@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" | ||
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== |
22 changes: 22 additions & 0 deletions
22
dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
export CI=true | ||
|
||
# New monorepo directory paths | ||
monorepo_dir="/app/monorepo" | ||
monorepo_openai_dir="/app/monorepo/libs/langchain-cohere" | ||
|
||
# Run the shared script to copy all necessary folders/files | ||
bash /scripts/with_standard_tests/shared.sh cohere | ||
|
||
# Navigate back to monorepo root and install dependencies | ||
cd "$monorepo_dir" | ||
yarn | ||
|
||
# Navigate into `@langchain/cohere` to build and run tests | ||
# We need to run inside the cohere directory so turbo repo does | ||
# not try to build the package/its workspace dependencies. | ||
cd "$monorepo_openai_dir" | ||
yarn test |
35 changes: 35 additions & 0 deletions
35
dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
export CI=true | ||
|
||
monorepo_dir="/app/monorepo" | ||
monorepo_cohere_dir="/app/monorepo/libs/langchain-cohere" | ||
updater_script_dir="/app/updater_script" | ||
updater_script_dir="/app/updater_script" | ||
original_updater_script_dir="/scripts/with_standard_tests/cohere/node" | ||
|
||
# Run the shared script to copy all necessary folders/files | ||
bash /scripts/with_standard_tests/shared.sh cohere | ||
|
||
# Copy the updater script to the monorepo | ||
mkdir -p "$updater_script_dir" | ||
cp "$original_updater_script_dir"/* "$updater_script_dir/" | ||
|
||
# Install deps (e.g semver) for the updater script | ||
cd "$updater_script_dir" | ||
yarn | ||
# Run the updater script | ||
node "update_resolutions_lowest.js" | ||
|
||
|
||
# Navigate back to monorepo root and install dependencies | ||
cd "$monorepo_dir" | ||
yarn | ||
|
||
# Navigate into `@langchain/cohere` to build and run tests | ||
# We need to run inside the cohere directory so turbo repo does | ||
# not try to build the package/its workspace dependencies. | ||
cd "$monorepo_cohere_dir" | ||
yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.