Skip to content

Commit

Permalink
upgrade dependencies, clean up env files, updated pdfloader
Browse files Browse the repository at this point in the history
  • Loading branch information
mayooear committed May 25, 2023
1 parent f1ee996 commit 0a6dc57
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 34 deletions.
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
OPENAI_API_KEY=

# Update these with your Supabase details from your project settings > API and dashboard settings
PINECONE_API_KEY=
# Update these with your pinecone details from your dashboard.
# PINECONE_INDEX_NAME is in the indexes tab under "index name" in blue
# PINECONE_ENVIRONMENT is in indexes tab under "Environment". Example: "us-east1-gcp"
PINECONE_API_KEY=
PINECONE_ENVIRONMENT=
PINECONE_INDEX_NAME=
PINECONE_INDEX_NAME=
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Prelude: Please make sure you have already downloaded node on your system and th
git clone [github https url]
```


2. Install packages

First run `npm install yarn -g` to install yarn globally (if you haven't already).
Expand All @@ -32,6 +31,7 @@ Then run:
```
yarn install
```

After installation, you should now see a `node_modules` folder.

3. Set up your `.env` file
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
},
"dependencies": {
"@microsoft/fetch-event-source": "^2.0.1",
"@pinecone-database/pinecone": "0.0.12",
"@pinecone-database/pinecone": "0.0.14",
"@radix-ui/react-accordion": "^1.1.1",
"clsx": "^1.2.1",
"dotenv": "^16.0.3",
"langchain": "0.0.55",
"langchain": "0.0.82",
"lucide-react": "^0.125.0",
"next": "13.2.3",
"pdf-parse": "1.1.1",
Expand All @@ -43,9 +43,6 @@
"tsx": "^3.12.3",
"typescript": "^4.9.5"
},
"engines": {
"node": ">=18"
},
"keywords": [
"starter",
"gpt4",
Expand Down
4 changes: 2 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function Home() {
}>({
messages: [
{
message: 'Hi, what would you like to learn about this legal case?',
message: 'Hi, what would you like to learn about this document?',
type: 'apiMessage',
},
],
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function Home() {
<Layout>
<div className="mx-auto flex flex-col gap-4">
<h1 className="text-2xl font-bold leading-[1.1] tracking-tighter text-center">
Chat With Your Legal Docs
Chat With Your Docs
</h1>
<main className={styles.main}>
<div className={styles.cloud}>
Expand Down
8 changes: 5 additions & 3 deletions scripts/ingest-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
import { OpenAIEmbeddings } from 'langchain/embeddings/openai';
import { PineconeStore } from 'langchain/vectorstores/pinecone';
import { pinecone } from '@/utils/pinecone-client';
import { CustomPDFLoader } from '@/utils/customPDFLoader';
import { PDFLoader } from 'langchain/document_loaders/fs/pdf';
import { PINECONE_INDEX_NAME, PINECONE_NAME_SPACE } from '@/config/pinecone';
import { DirectoryLoader } from 'langchain/document_loaders/fs/directory';

/* Name of directory to retrieve your files from */
/* Name of directory to retrieve your files from
Make sure to add your PDF files inside the 'docs' folder
*/
const filePath = 'docs';

export const run = async () => {
try {
/*load raw docs from the all files in the directory */
const directoryLoader = new DirectoryLoader(filePath, {
'.pdf': (path) => new CustomPDFLoader(path),
'.pdf': (path) => new PDFLoader(path),
});

// const loader = new PDFLoader(filePath);
Expand Down
53 changes: 33 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
dependencies:
regenerator-runtime "^0.13.11"

"@dqbd/tiktoken@^1.0.4":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@dqbd/tiktoken/-/tiktoken-1.0.6.tgz#96bfd0a4909726c61551a8c783493f01841bd163"
integrity sha512-umSdeZTy/SbPPKVuZKV/XKyFPmXSN145CcM3iHjBbmhlohBJg7vaDp4cPCW+xNlWL6L2U1sp7T2BD+di2sUKdA==

"@esbuild-kit/cjs-loader@^2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@esbuild-kit/cjs-loader/-/cjs-loader-2.4.2.tgz#cb4dde00fbf744a68c4f20162ea15a8242d0fa54"
Expand Down Expand Up @@ -340,10 +335,10 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@pinecone-database/[email protected].12":
version "0.0.12"
resolved "https://registry.yarnpkg.com/@pinecone-database/pinecone/-/pinecone-0.0.12.tgz#c40c10464c04c9e2f31fe363c1785177fe3f4868"
integrity sha512-YI9IQ7/0k6jI+NUyTD+I2BvwUGhOMRgMpx/qx/v5t5Cm31vSdnXEgGfh9jILUpi/+j59vtK+O5rB+pV5v1L15w==
"@pinecone-database/[email protected].14":
version "0.0.14"
resolved "https://registry.yarnpkg.com/@pinecone-database/pinecone/-/pinecone-0.0.14.tgz#a74e387843327c2d2cfdecf294e233e2ab95e230"
integrity sha512-uQspP/fGB2xhS/PWVD9/XnNnzuTfjukuX9IKH0EYqJMXd0Yx+ewcRADVFrF5RBeBWXBWrpGhIhvWE0hTPy/BAg==
dependencies:
cross-fetch "^3.1.5"

Expand Down Expand Up @@ -644,6 +639,11 @@ ansi-styles@^4.1.0:
dependencies:
color-convert "^2.0.1"

ansi-styles@^5.0.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b"
integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==

any-promise@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
Expand Down Expand Up @@ -785,6 +785,11 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base64-js@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

binary-extensions@^2.0.0, binary-extensions@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
Expand All @@ -810,11 +815,6 @@ braces@^3.0.2, braces@~3.0.2:
dependencies:
fill-range "^7.0.1"

browser-or-node@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/browser-or-node/-/browser-or-node-2.1.1.tgz#738790b3a86a8fc020193fa581273fbe65eaea0f"
integrity sha512-8CVjaLJGuSKMVTxJ2DpBl5XnlNDiT4cQFeuCJJrvJmts9YrTZDizTX7PjC2s6W4x+MBGZeEY6dGMrF04/6Hgqg==

browserslist@^4.21.5:
version "4.21.5"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.5.tgz#75c5dae60063ee641f977e00edd3cfb2fb7af6a7"
Expand Down Expand Up @@ -2003,6 +2003,13 @@ js-sdsl@^4.1.4:
resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.4.0.tgz#8b437dbe642daa95760400b602378ed8ffea8430"
integrity sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==

js-tiktoken@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/js-tiktoken/-/js-tiktoken-1.0.6.tgz#f32f4b9b3c33d11f12b5cf016b3c729370817ee9"
integrity sha512-lxHntEupgjWvSh37WxpAW4XN6UBXBtFJOpZZq5HN5oNjDfN7L/iJhHOKjyL/DFtuYXUwn5jfTciLtOWpgQmHjQ==
dependencies:
base64-js "^1.5.1"

"js-tokens@^3.0.0 || ^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down Expand Up @@ -2050,17 +2057,17 @@ kleur@^4.0.3:
resolved "https://registry.yarnpkg.com/kleur/-/kleur-4.1.5.tgz#95106101795f7050c6c650f350c683febddb1780"
integrity sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==

[email protected].55:
version "0.0.55"
resolved "https://registry.yarnpkg.com/langchain/-/langchain-0.0.55.tgz#8ea781a33fcd30ca48411efe6a765d1ceb3c2971"
integrity sha512-ScL53LvBm2X0rIO1fdMLEoCFYESLVTmY0d71qX7qDrB1y8Y8nCtCA1ZiUNYl4WDQeEvKcvB39qWmAJ2XcB8tqQ==
[email protected].82:
version "0.0.82"
resolved "https://registry.yarnpkg.com/langchain/-/langchain-0.0.82.tgz#12b70a7ad95d50d73b8244360d2262fc75ec8fac"
integrity sha512-tRIfr7ktPHgB2IZBE5/dr6ExCnFv9CrF8+WhQH3rfpI9VBzMs8xAgyB4o4u5bYFVw8AKfd6e7Uj+LdYHS+Dlrg==
dependencies:
"@anthropic-ai/sdk" "^0.4.3"
"@dqbd/tiktoken" "^1.0.4"
ansi-styles "^5.0.0"
binary-extensions "^2.2.0"
browser-or-node "^2.1.1"
expr-eval "^2.0.2"
flat "^5.0.2"
js-tiktoken "^1.0.6"
jsonpointer "^5.0.1"
ml-distance "^4.0.0"
object-hash "^3.0.0"
Expand All @@ -2070,6 +2077,7 @@ [email protected]:
uuid "^9.0.0"
yaml "^2.2.1"
zod "^3.21.4"
zod-to-json-schema "^3.20.4"

language-subtag-registry@~0.3.2:
version "0.3.22"
Expand Down Expand Up @@ -3557,6 +3565,11 @@ yocto-queue@^0.1.0:
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zod-to-json-schema@^3.20.4:
version "3.21.1"
resolved "https://registry.yarnpkg.com/zod-to-json-schema/-/zod-to-json-schema-3.21.1.tgz#a24b2737bf361fc516c92421eb59988b6e2fc046"
integrity sha512-y5g0MPxDq+YG/T+cHGPYH4PcBpyCqwK6wxeJ76MR563y0gk/14HKfebq8xHiItY7lkc9GDFygCnkvNDTvAhYAg==

zod@^3.21.4:
version "3.21.4"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.4.tgz#10882231d992519f0a10b5dd58a38c9dabbb64db"
Expand Down

0 comments on commit 0a6dc57

Please sign in to comment.