-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a1615f
Showing
43 changed files
with
8,614 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
OPENAI_API_KEY= |
This file contains 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 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains 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,52 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# python | ||
*/venv/**/* | ||
__pycache__ | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# temp | ||
/public/tmp/* | ||
|
||
# python | ||
*/venv/**/* | ||
__pycache__ | ||
|
||
vectorstore/ | ||
*/vectorstores/ | ||
eng.** |
This file contains 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,13 @@ | ||
module.exports = { | ||
bracketSpacing: false, | ||
jsxBracketSameLine: true, | ||
singleQuote: true, | ||
trailingComma: 'es5', | ||
semi: false, | ||
printWidth: 100, | ||
tabWidth: 2, | ||
useTabs: false, | ||
importOrder: ['^\\u0000', '^@?\\w', '^[^.]', '^\\.'], | ||
importOrderSeparation: true, | ||
plugins: ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-tailwindcss"] | ||
}; |
This file contains 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,9 @@ | ||
ARG PNPM_VERSION=8.7.1 | ||
FROM node:20.6.1 | ||
|
||
COPY . ./langchain-selfquery | ||
WORKDIR /langchain-selfquery | ||
|
||
RUN npm install -g pnpm@${PNPM_VERSION} | ||
|
||
ENTRYPOINT pnpm install && pnpm run build && pnpm start |
This file contains 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,29 @@ | ||
# langchain-selfquery | ||
|
||
Simple chat app integrating LangChain + RAG + SelfQuery to demonstrate an error when parsing user prompt | ||
|
||
## Running | ||
|
||
`cp .env.example .env` | ||
Edit .env and add your OpenAI API key | ||
|
||
`docker compose up` or `pnpm run dev` | ||
|
||
App will start at `localhost:3000` | ||
|
||
## Reproducing | ||
|
||
1. Run the app | ||
2. Upload any txt file using the clip icon | ||
2.1 The file will be embedded and a vectorstore folder will be created for RAG | ||
3. Ask any of the following questions: | ||
|
||
- How do CAN and LIN signals join in automotive networks as of ISO 11898 version 2.0? | ||
- Where do Zigbee and Wi-Fi signals coexist in IoT devices as of IEEE 802.15.4? | ||
- How do OPC and MQTT protocols select data in IIoT as defined by IEC 62541 version 1.4? | ||
- Where do USB and Ethernet standards join in smart homes as per IEEE 802.3 version 1.0? | ||
|
||
You should see the following error in the console: | ||
`Failed to import peggy. Please install peggy (i.e. "npm install peggy" or "yarn add peggy").` thrown by `/node_modules/langchain/dist/output_parsers/expression_type_handlers/base.js` | ||
|
||
The criteria seems to be sending SQL words (`as`, `where`, `select`, `from`, `join`) along as a word matching the AttributeInfo (in this case, `version`) in some specific length. Anything different from that would work. |
This file contains 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,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": true, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.ts", | ||
"css": "src/app/globals.css", | ||
"baseColor": "gray", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |
This file contains 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,14 @@ | ||
services: | ||
langchain-selfquery: | ||
container_name: langchain-selfquery | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
environment: | ||
OPENAI_API_KEY: ${OPENAI_API_KEY} | ||
ports: | ||
- 3000:3000 | ||
entrypoint: sh -c "pnpm install && pnpm run build && pnpm run dev" | ||
working_dir: /langchain-selfquery | ||
volumes: | ||
- .:/langchain-selfquery |
This file contains 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,12 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
webpack(config) { | ||
config.externals = config.externals || [] | ||
config.externals = [...config.externals, 'langchain', '@langchain/openai', 'hnswlib-node'] | ||
config.resolve.alias['fs'] = false | ||
|
||
return config | ||
}, | ||
} | ||
|
||
export default nextConfig |
This file contains 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,57 @@ | ||
{ | ||
"name": "nextjs-chat-rag", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start", | ||
"format": "prettier --write \"**/*.ts\" \"**/*.tsx\"", | ||
"lint": "next lint" | ||
}, | ||
"dependencies": { | ||
"@langchain/community": "^0.3.14", | ||
"@langchain/core": "^0.3.18", | ||
"@langchain/openai": "^0.3.13", | ||
"@radix-ui/react-label": "^2.0.2", | ||
"@radix-ui/react-separator": "^1.0.3", | ||
"@radix-ui/react-slot": "^1.0.2", | ||
"ai": "^3.4.33", | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.0", | ||
"date-fns": "^3.6.0", | ||
"highlight.js": "^11.9.0", | ||
"hnswlib-node": "^3.0.0", | ||
"langchain": "^0.3.5", | ||
"lucide-react": "^0.363.0", | ||
"next": "14.1.4", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"react-markdown": "^9.0.1", | ||
"rehype-highlight": "^7.0.0", | ||
"tailwind-merge": "^2.2.2", | ||
"tailwindcss-animate": "^1.0.7", | ||
"zustand": "^4.5.2" | ||
}, | ||
"devDependencies": { | ||
"@tailwindcss/typography": "^0.5.10", | ||
"@trivago/prettier-plugin-sort-imports": "github:trivago/prettier-plugin-sort-imports", | ||
"@types/node": "^20", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"autoprefixer": "^10.0.1", | ||
"css-loader": "^6.10.0", | ||
"eslint": "^8", | ||
"eslint-config-next": "14.1.4", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.2", | ||
"postcss": "^8", | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-tailwindcss": "^0.5.12", | ||
"style-loader": "^3.3.4", | ||
"tailwindcss": "^3.3.0", | ||
"typescript": "^5", | ||
"zod": "^3.22.4" | ||
}, | ||
"packageManager": "[email protected]+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee" | ||
} |
Oops, something went wrong.