-
Notifications
You must be signed in to change notification settings - Fork 16
- Add langchain-oracle-js #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
37e0e4f
577556b
2936033
b3f1672
9e90a3c
fdb8fa4
a895364
d9d45d7
81974ef
c695672
ec46845
93432fe
91293ef
277ace4
8949367
b1099ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| index.cjs | ||
| index.js | ||
| index.d.ts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| The MIT License | ||
|
|
||
| Copyright (c) 2023 LangChain | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # @langchain/cohere | ||
|
|
||
| This package contains the LangChain.js integrations for Cohere through their SDK. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash npm2yarn | ||
| npm install @langchain/cohere @langchain/core | ||
| ``` | ||
|
|
||
| This package, along with the main LangChain package, depends on [`@langchain/core`](https://npmjs.com/package/@langchain/core/). | ||
| If you are using this package with other LangChain packages, you should make sure that all of the packages depend on the same instance of @langchain/core. | ||
| You can do so by adding appropriate field to your project's `package.json` like this: | ||
|
|
||
| ```json | ||
| { | ||
| "name": "your-project", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the name should be updated here to probably "@langchain/oracle".
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name is application using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ok. Got it |
||
| "version": "0.0.0", | ||
|
||
| "dependencies": { | ||
| "@langchain/cohere": "^0.0.1", | ||
| "@langchain/core": "^0.3.0", | ||
| }, | ||
| "resolutions": { | ||
| "@langchain/core": "0.3.0" | ||
| }, | ||
| "overrides": { | ||
| "@langchain/core": "0.3.0" | ||
| }, | ||
| "pnpm": { | ||
| "overrides": { | ||
| "@langchain/core": "0.3.0" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The field you need depends on the package manager you're using, but we recommend adding a field for the common `yarn`, `npm`, and `pnpm` to maximize compatibility. | ||
|
|
||
| ## Chat Models | ||
|
|
||
| This package contains the `ChatCohere` class, which is the recommended way to interface with the Cohere series of models. | ||
|
|
||
| To use, install the requirements, and configure your environment. | ||
|
|
||
| ```bash | ||
| export COHERE_API_KEY=your-api-key | ||
| ``` | ||
|
|
||
| Then initialize | ||
|
|
||
| ```typescript | ||
| import { HumanMessage } from "@langchain/core/messages"; | ||
| import { ChatCohere } from "@langchain/cohere"; | ||
|
|
||
| const model = new ChatCohere({ | ||
| apiKey: process.env.COHERE_API_KEY, | ||
| }); | ||
| const response = await model.invoke([new HumanMessage("Hello world!")]); | ||
| ``` | ||
|
|
||
| ### Streaming | ||
|
|
||
| ```typescript | ||
| import { HumanMessage } from "@langchain/core/messages"; | ||
| import { ChatCohere } from "@langchain/cohere"; | ||
|
|
||
| const model = new ChatCohere({ | ||
| apiKey: process.env.COHERE_API_KEY, | ||
| }); | ||
| const response = await model.stream([new HumanMessage("Hello world!")]); | ||
| ``` | ||
|
|
||
| ## Embeddings | ||
|
|
||
| This package also adds support for `CohereEmbeddings` embeddings model. | ||
|
|
||
| ```typescript | ||
| import { ChatCohere } from "@langchain/cohere"; | ||
|
|
||
| const embeddings = new ChatCohere({ | ||
| apiKey: process.env.COHERE_API_KEY, | ||
| }); | ||
| const res = await embeddings.embedQuery("Hello world"); | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| To develop the `@langchain/cohere` package, you'll need to follow these instructions: | ||
|
|
||
| ### Install dependencies | ||
|
|
||
| ```bash | ||
| yarn install | ||
| ``` | ||
|
|
||
| ### Build the package | ||
|
|
||
| ```bash | ||
| yarn build | ||
| ``` | ||
|
|
||
| Or from the repo root: | ||
|
|
||
| ```bash | ||
| yarn build --filter=@langchain/cohere | ||
| ``` | ||
|
|
||
| ### Run tests | ||
|
|
||
| Test files should live within a `tests/` file in the `src/` folder. Unit tests should end in `.test.ts` and integration tests should | ||
| end in `.int.test.ts`: | ||
|
|
||
| ```bash | ||
| $ yarn test | ||
| $ yarn test:int | ||
| ``` | ||
|
|
||
| ### Lint & Format | ||
|
|
||
| Run the linter & formatter to ensure your code is up to standard: | ||
|
|
||
| ```bash | ||
| yarn lint && yarn format | ||
| ``` | ||
|
|
||
| ### Adding new entrypoints | ||
|
|
||
| If you add a new file to be exported, either import & re-export from `src/index.ts`, or add it to the `entrypoints` field in the `config` variable located inside `langchain.config.js` and run `yarn build` to generate the new entrypoint. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // babel.config.js | ||
| module.exports = { | ||
| presets: [["@babel/preset-env", { targets: { node: true } }]], | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // eslint.config.cjs — CJS flat config compatible with ESLint v9 + TS-ESLint v8 | ||
|
|
||
| const js = require("@eslint/js"); | ||
| const tseslint = require("typescript-eslint"); | ||
| const prettier = require("eslint-config-prettier"); | ||
| const noInstanceOf = require("eslint-plugin-no-instanceof"); | ||
| const importPlugin = require("eslint-plugin-import"); | ||
|
|
||
| module.exports = [ | ||
| js.configs.recommended, | ||
| prettier, | ||
| ...tseslint.configs.recommended, | ||
|
|
||
| { | ||
| files: ["src/**/*.{ts,js,tsx,jsx}"], | ||
|
|
||
| ignores: [ | ||
| "src/utils/@cfworker", | ||
| "src/utils/fast-json-patch", | ||
| "src/utils/js-sha1", | ||
| ".eslintrc.cjs", | ||
| "scripts", | ||
| "node_modules", | ||
| "dist", | ||
| "dist-cjs", | ||
| "*.js", | ||
| "*.cjs", | ||
| "*.d.ts", | ||
| ], | ||
|
|
||
| languageOptions: { | ||
| ecmaVersion: "latest", | ||
| sourceType: "module", | ||
| parser: tseslint.parser, | ||
| parserOptions: { | ||
| project: "./tsconfig.json", | ||
| }, | ||
| }, | ||
|
|
||
| plugins: { | ||
| "@typescript-eslint": tseslint.plugin, | ||
| "no-instanceof": noInstanceOf, | ||
| import: importPlugin, | ||
| }, | ||
|
|
||
| rules: { | ||
| "no-process-env": 2, | ||
| "no-instanceof/no-instanceof": 2, | ||
|
|
||
| "@typescript-eslint/explicit-module-boundary-types": 0, | ||
| "@typescript-eslint/no-empty-function": 0, | ||
| "@typescript-eslint/no-shadow": 0, | ||
| "@typescript-eslint/no-empty-interface": 0, | ||
| "@typescript-eslint/no-use-before-define": [ | ||
| "error", | ||
| { functions: false, classes: true, variables: true }, | ||
| ], | ||
| "@typescript-eslint/no-unused-vars": ["warn", { args: "none" }], | ||
| "@typescript-eslint/no-floating-promises": "error", | ||
| "@typescript-eslint/no-misused-promises": "error", | ||
|
|
||
| camelcase: 0, | ||
| "class-methods-use-this": 0, | ||
| "import/extensions": [2, "ignorePackages"], | ||
| "import/no-extraneous-dependencies": [ | ||
| "error", | ||
| { devDependencies: ["**/*.test.ts"] }, | ||
| ], | ||
| "import/no-unresolved": 0, | ||
| "import/prefer-default-export": 0, | ||
|
|
||
| "keyword-spacing": "error", | ||
| "max-classes-per-file": 0, | ||
| "max-len": 0, | ||
| "no-await-in-loop": 0, | ||
| "no-bitwise": 0, | ||
| "no-console": 0, | ||
| "no-restricted-syntax": 0, | ||
| "no-shadow": 0, | ||
| "no-continue": 0, | ||
| "no-void": 0, | ||
| "no-underscore-dangle": 0, | ||
| "no-use-before-define": 0, | ||
| "no-useless-constructor": 0, | ||
| "no-return-await": 0, | ||
| "consistent-return": 0, | ||
| "no-else-return": 0, | ||
| "func-names": 0, | ||
| "no-lonely-if": 0, | ||
| "prefer-rest-params": 0, | ||
| "new-cap": ["error", { properties: false, capIsNew: false }], | ||
| }, | ||
| }, | ||
| ]; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { resolve, dirname } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| /** | ||
| * @param {string} relativePath | ||
| * @returns {string} | ||
| */ | ||
| function abs(relativePath) { | ||
| return resolve(dirname(fileURLToPath(import.meta.url)), relativePath); | ||
| } | ||
|
|
||
|
|
||
| export const config = { | ||
| internals: [/node\:/, /@langchain\/core\//], | ||
| entrypoints: { | ||
| index: "index", | ||
| }, | ||
| tsConfigPath: resolve("./tsconfig.json"), | ||
| cjsSource: "./dist-cjs", | ||
| cjsDestination: "./dist", | ||
| abs, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| { | ||
| "name": "@langchain/oracle", | ||
| "version": "0.3.1", | ||
| "description": "Oracle integration for LangChain.js", | ||
|
||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=18" | ||
| }, | ||
| "main": "./index.js", | ||
| "types": "./index.d.ts", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "[email protected]:langchain-ai/langchainjs.git" | ||
| }, | ||
| "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-oracle/", | ||
| "scripts": { | ||
| "build": "pnpm clean && pnpm build:esm && pnpm build:cjs && pnpm build:scripts", | ||
| "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", | ||
| "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rm -rf dist-cjs", | ||
| "build:watch": "node scripts/create-entrypoints.js && tsc --outDir dist/ --watch", | ||
| "build:scripts": "node scripts/create-entrypoints.js && node scripts/check-tree-shaking.js", | ||
| "lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint src && dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", | ||
| "lint:fix": "pnpm lint --fix", | ||
| "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre", | ||
| "prepack": "pnpm build", | ||
| "release": "release-it --only-version --config .release-it.json", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "test:int": "vitest run --mode int", | ||
| "test:standard:unit": "vitest run --mode standard-unit", | ||
| "test:standard:int": "vitest run --mode standard-int", | ||
| "test:standard": "pnpm test:standard:unit && pnpm test:standard:int", | ||
| "format": "prettier --write \"src\"", | ||
| "format:check": "prettier --check \"src\"" | ||
| }, | ||
| "author": "LangChain", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "htmlparser2": "^10.0.0", | ||
| "oracledb": "^6.10.0", | ||
| "uuid": "^10.0.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "@langchain/core": "^1.0.0", | ||
| "@langchain/textsplitters": "^1.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@langchain/core": "^1.0.0", | ||
| "@langchain/textsplitters": "^1.0.0", | ||
| "@swc/core": "^1.3.90", | ||
| "@tsconfig/recommended": "^1.0.3", | ||
| "@types/oracledb": "^6.10.0", | ||
| "@typescript-eslint/eslint-plugin": "^6.12.0", | ||
| "@typescript-eslint/parser": "^6.12.0", | ||
| "@vitest/coverage-v8": "^4.0.15", | ||
| "dotenv": "^17.2.3", | ||
| "dpdm": "^3.12.0", | ||
| "eslint": "^8.33.0", | ||
| "eslint-config-prettier": "^8.6.0", | ||
| "eslint-plugin-import": "^2.27.5", | ||
| "eslint-plugin-no-instanceof": "^1.0.1", | ||
| "eslint-plugin-prettier": "^4.2.1", | ||
| "prettier": "^2.8.3", | ||
| "rollup": "^4.5.2", | ||
| "typescript": "<5.2.0", | ||
| "typescript-eslint": "^8.48.1", | ||
| "vitest": "^3.2.4" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "exports": { | ||
| ".": { | ||
| "types": "./index.d.ts", | ||
| "import": "./index.js", | ||
| "require": "./index.cjs" | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "files": [ | ||
| "dist/", | ||
| "index.cjs", | ||
| "index.js", | ||
| "index.d.ts" | ||
| ] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated to include installing langchain/oracle like
npm install @langchain/oracle