@oracle/langchain-oracledb
v0.2.0
Published
Oracle Database integration for LangChain.js
Readme
@oracle/langchain-oracledb
This package contains the LangChain.js integrations for Oracle Database.
Installation
npm install @oracle/langchain-oracledb @langchain/coreThis package, along with the main LangChain package, depends on @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 an appropriate field to your project's package.json like this:
{
"name": "your-project",
"version": "0.1.0",
"dependencies": {
"@oracle/langchain-oracledb": "^0.1.1",
"@langchain/core": "^1.0.0"
},
"resolutions": {
"@langchain/core": "^1.0.0"
},
"overrides": {
"@langchain/core": "^1.0.0"
},
"pnpm": {
"overrides": {
"@langchain/core": "^1.0.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.
import {OracleDocLoader} from "@oracle/langchain-oracledb";
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.
import {OracleTextSplitter} from "@oracle/langchain-oracledb";
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.
import {OracleEmbeddings} from "@oracle/langchain-oracledb";
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.
import {OracleSummary} from "@oracle/langchain-oracledb";
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.
import {OracleVS} from "@oracle/langchain-oracledb";
oraclevs = new OracleVS(embedder, dbConfig);
await oraclevs.initialize();
await oraclevs.addDocuments(docs);
const results = await oraclevs.similaritySearch("hello!", 3);Development
To develop the @oracle/langchain-oracledb package, you'll need to follow these instructions:
Install dependencies
pnpm installBuild the package
pnpm buildOr from the repo root:
pnpm build --filter @oracle/langchain-oracledbRun 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:
$ pnpm test
$ pnpm test:intLint & Format
Run the linter & formatter to ensure your code is up to standard:
pnpm lint && pnpm formatAdding 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.
