Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmadHakim2004 committed Nov 29, 2024
1 parent ceb15ad commit 4542909
Showing 1 changed file with 5 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
hide_table_of_contents: true
---

import Example from "@examples/document_loaders/oracleai";
import CodeBlock from "@theme/CodeBlock";

# Oracle AI

This example goes over how to load documents using Oracle AI Vector Search.
Expand All @@ -17,30 +20,7 @@ npm install @langchain/community @langchain/core oracledb
## Usage

### Connect to Oracle Database
You'll need to provide the username, password, hostname and service_name:

```typescript
import oracledb from 'oracledb';

let connection: oracledb.Connection;

// Replace the placeholders with your information
const username = "<username>";
const password = "<password>";
const dsn = "<hostname>/<service_name>";

try {
connection = await oracledb.getConnection({
user: username,
password:password,
connectString: dsn
});
console.log("Connection Successful");
} catch (err) {
console.error('Connection failed:', err);
throw err;
}
```
You'll need to set up an Oracle Database and connect to it providing your username, password, hostname and service_name:

### Load Documents
As for loading documents, you have 3 options:
Expand All @@ -50,24 +30,5 @@ As for loading documents, you have 3 options:

When loading from the Oracle Database, you must provide the table's name, owner's name, and the name of the column to load. Optionally, you can provide extra column names to be included in the returned documents' metadata:

```typescript
import { OracleDocLoader, OracleLoadFromType } from "@langchain/community/document_loaders/web/oracleai";

/*
// Loading a local file (replace <filepath> with the path of the file you want to load.)
const loader = new OracleDocLoader(connection, <filepath>, OracleLoadFromType.FILE);
// Loading from a local directory (replace <dirpath> with the path of the directory you want to load from.)
const loader = new OracleDocLoader(connection, <dirpath>, OracleLoadFromType.DIR);
*/

// Loading from Oracle Database table (replace the placeholders with your information, optionally add a [metadata_cols] parameter to include columns as metadata.)
const loader = new OracleDocLoader(connection, <tablename>, OracleLoadFromType.TABLE, <owner_name>, <colname>);

// Load the docs
const docs = loader.load();
console.log("Number of docs loaded:", docs.length);
console.log("Document-0:", docs[0].page_content); // content
```
<CodeBlock language="typescript">{Example}</CodeBlock>

0 comments on commit 4542909

Please sign in to comment.