Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libs/js/oracledb/langchain-oracledb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
index.cjs
index.js
index.d.ts
21 changes: 21 additions & 0 deletions libs/js/oracledb/langchain-oracledb/LICENSE
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.
141 changes: 141 additions & 0 deletions libs/js/oracledb/langchain-oracledb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# @langchain/oracle

This package contains the LangChain.js integrations for Oracle through their SDK.

## Installation

```bash npm2yarn
npm install @langchain/oracle @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/oracle": "^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.

## Document Loaders

This package includes a document loader for loading documents from different sources and file formats.

```typescript
import {OracleDocLoader} from "@langchain/oracle";

const loader = new OracleDocLoader(conn, loader_params);
const docs = await loader.load();
```

## Text Splitter

This package includes a text splitter for chunking documents using the database.

```typescript
import {OracleTextSplitter} from "@langchain/oracle";

const splitter = new OracleTextSplitter(conn, splitter_params);
let chunks = await splitter.splitText(doc.pageContent);
```

## Embeddings

This package includes a class for generating embeddings either inside or outside of the database.

```typescript
import {OracleEmbeddings} from "@langchain/oracle";

const embedder = new OracleEmbeddings(conn, embedder_params, proxy);
const embed = await embedder.embedQuery(chunk);
```

## Summary

This package includes a class for generating summaries either inside or outside of the database.

Please check the [usage example](/docs/integrations/tools/oracleai).

```typescript
import {OracleSummary} from "@langchain/oracle";

const model = new OracleSummary(conn, summary_params, proxy);
const summary = await model.getSummary(doc.pageContent);
```

## Vector Store

This package includes a vector store for storing, indexing, and querying data in the database.

```typescript
import {OracleVS} from "@langchain/oracle";

oraclevs = new OracleVS(embedder, dbConfig);
await oraclevs.initialize();

await oraclevs.addDocuments(docs);
const results = await oraclevs.similaritySearch("hello!", 3);
```

## Development

To develop the `@langchain/oracle` package, you'll need to follow these instructions:

### Install dependencies

```bash
pnpm install
```

### Build the package

```bash
pnpm build
```

Or from the repo root:

```bash
pnpm build --filter @langchain/oracle
```

### 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
$ pnpm test
$ pnpm test:int
```

### Lint & Format

Run the linter & formatter to ensure your code is up to standard:

```bash
pnpm lint && pnpm 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 `exports` field in the `package.json` file and run `pnpm build` to generate the new entrypoint.
4 changes: 4 additions & 0 deletions libs/js/oracledb/langchain-oracledb/babel.config.cjs
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 } }]],
};
94 changes: 94 additions & 0 deletions libs/js/oracledb/langchain-oracledb/eslint.config.cjs
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 }],
},
},
];
22 changes: 22 additions & 0 deletions libs/js/oracledb/langchain-oracledb/langchain.config.js
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,
}
86 changes: 86 additions & 0 deletions libs/js/oracledb/langchain-oracledb/package.json
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oracle Database integration for langchain.js

"type": "module",
"engines": {
"node": ">=18"
},
"main": "./index.js",
"types": "./index.d.ts",
"repository": {
"type": "git",
"url": "git@github.com: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"
]
}
Loading