generated from oracle/template-repo
-
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
Open
sudarshan12s
wants to merge
8
commits into
oracle:main
Choose a base branch
from
sudarshan12s:langchainjssupport
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
37e0e4f
- Add langchain-oracle-js
sudarshan12s 577556b
- Remove workspace
sudarshan12s 2936033
- Moved to js folder as per suggestion
sudarshan12s b3f1672
- Add lint, packaging rules
sudarshan12s 9e90a3c
- use eslint as per template https://github.com/langchain-ai/langchai…
sudarshan12s fdb8fa4
- correct tsconfig
sudarshan12s a895364
- generate cjs too
sudarshan12s d9d45d7
- Rremove jest related configs
sudarshan12s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| index.cjs | ||
| index.js | ||
| index.d.ts |
This file contains hidden or 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,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. |
This file contains hidden or 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,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", | ||
| "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. | ||
This file contains hidden or 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,4 @@ | ||
| // babel.config.js | ||
| module.exports = { | ||
| presets: [["@babel/preset-env", { targets: { node: true } }]], | ||
| }; |
This file contains hidden or 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,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 }], | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or 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 @@ | ||
| 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, | ||
| } |
This file contains hidden or 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,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" | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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