Skip to content

Commit f990d34

Browse files
authored
Merge pull request #2 from WillACosta/feature/implement-rag
[AUTOMATED-PR] - main <- feature/implement-rag
2 parents 6533b23 + b608eca commit f990d34

File tree

32 files changed

+1083
-208
lines changed

32 files changed

+1083
-208
lines changed

.dockerignore

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Dependency directories
2+
node_modules
3+
pnpm-store
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
24+
# nyc test coverage
25+
.nyc_output
26+
27+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (https://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
.env.test
60+
61+
# parcel-bundler cache (https://parceljs.org/)
62+
.cache
63+
64+
# Next.js build output
65+
.next
66+
67+
# Nuxt.js build / generate output
68+
.nuxt
69+
dist
70+
71+
# Gatsby files
72+
.cache/
73+
public
74+
75+
# vuepress build output
76+
.vuepress/dist
77+
78+
# Serverless directories
79+
.serverless/
80+
81+
# FuseBox cache
82+
.fusebox/
83+
84+
# DynamoDB Local files
85+
.dynamodb/
86+
87+
# TernJS port file
88+
.tern-port
89+
90+
# IDE / Editor directories
91+
.idea
92+
.vscode
93+
*.swp
94+
*.swo
95+
96+
# OS files
97+
.DS_Store
98+
Thumbs.db
99+
100+
# Docker files
101+
Dockerfile
102+
docker-compose.yaml
103+
104+
# App
105+
*.pdf
106+
docs
107+
.gitignore

.env-example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
LANGCHAIN_API_KEY=
22
LANGCHAIN_TRACING_V2=true
33
LANGCHAIN_CALLBACKS_BACKGROUND=true
4-
GEMINI_API_KEY=
4+
5+
GOOGLE_GENAI_API_KEY=
6+
7+
REDIS_ENDPOINT_URI=localhost:6379
8+
REDIS_PASSWORD=redis@dev

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"cSpell.words": [
3+
"dataproviders",
34
"gemini",
45
"nodenext",
56
"usecases"

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Gen-AI API with Langchain and NodeJS
22

3-
This is an Express service written in [TypeScript](https://www.typescriptlang.org/) that provides authorization functionality and includes gen-AI features.
3+
This is an Express service written in [TypeScript](https://www.typescriptlang.org/) that provides authorization functionality and includes gen-AI features, using RAG concepts, vector database and implements AI memory history with Redis DB.
44

55
> 🌱 This project is under development.
66
@@ -12,3 +12,29 @@ This is an Express service written in [TypeScript](https://www.typescriptlang.or
1212
- [JWT](https://jwt.io/) for handling authentication
1313
- [GoogleGenAI](https://v02.api.js.langchain.com/modules/_langchain_google_genai.html) langchain plugin.
1414
- [Google Gemini - API](https://ai.google.dev/)
15+
- [Docker](https://docs.docker.com/) Containers for setting up environment.
16+
- [Redis](https://redis.io/) database for storing AI messages.
17+
18+
## Running the application
19+
20+
1. Clone this repository
21+
22+
```shell
23+
git clone https://github.com/WillACosta/genai-langchain-api
24+
```
25+
26+
> Copy the `.env.example` file to `.env` and fill it with your own credentials
27+
28+
```shell
29+
cp .env.example .env
30+
```
31+
32+
2. You'll need [Docker](https://docs.docker.com/) to setup and running the application services
33+
34+
> From the app's root directory, run the following command to build and running docker containers:
35+
36+
```shell
37+
docker compose up --build
38+
```
39+
40+
> The application will be available at `http://localhost:3000`.

docker-compose.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
ports:
9+
- '3000:3000'
10+
env_file:
11+
- .env
12+
volumes:
13+
- ./src:/usr/workspace/app/src
14+
- pnpm_store:/pnpm/.pnpm-store
15+
command: sh -c "pnpm install && pnpm dev"
16+
17+
postgres:
18+
image: bitnami/postgresql:latest
19+
ports:
20+
- '5432:5432'
21+
environment:
22+
- POSTGRES_USER=docker
23+
- POSTGRES_PASSWORD=docker
24+
- POSTGRES_DB=rag_app
25+
volumes:
26+
- 'rag_app_postgres_data:/bitnami/postgresql'
27+
28+
redis:
29+
image: bitnami/redis:latest
30+
ports:
31+
- '6379:6379'
32+
environment:
33+
- ALLOW_EMPTY_PASSWORD=yes
34+
volumes:
35+
- 'rag_app_redis_data:/bitnami/redis/data'
36+
37+
volumes:
38+
pnpm_store:
39+
rag_app_redis_data:
40+
rag_app_postgres_data:

dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:20-alpine
2+
3+
RUN npm install -g [email protected]
4+
WORKDIR /usr/workspace/app
5+
6+
ENV PNPM_HOME="/pnpm"
7+
ENV PATH="$PNPM_HOME:$PATH"
8+
RUN mkdir -p $PNPM_HOME
9+
10+
RUN pnpm config set store-dir "$PNPM_HOME/.pnpm-store" --global
11+
12+
COPY package.json pnpm-lock.yaml* ./
13+
RUN pnpm install --frozen-lockfile
14+
COPY . .
15+
16+
EXPOSE 3000
17+
CMD [ "pnpm", "start" ]

docs/prompts/ai-prompts.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
What is this document about?
2+
3+
This document is about AI and chatbot, can you summarize it for me?
4+
5+
Can you list it in a bullet list form?
6+
7+
What was my first question to you?

0 commit comments

Comments
 (0)