Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement MongoDB integration #1

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ci
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
ci:
name: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- run: pnpm i --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM node:20-alpine AS base

FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./

RUN corepack enable pnpm && pnpm i --frozen-lockfile;


FROM base AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
ENV NEXT_TELEMETRY_DISABLED=1

RUN corepack enable pnpm && pnpm run build;


FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

RUN mkdir .next
RUN chown nextjs:nodejs .next

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT=3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ The playground can be customized via environment variables, with default setting
To configure the playground for a local development environment, simply copy the contents of `.env` to a new file named
`.env.local`, and update the values as needed. This file is excluded from version control.

| Configuration variable | Description | Default value |
|-----------------------------|-----------------------------------------------------|-------------------------------------------|
| SYSTEM_MESSAGE | System message that defines the behaviour of the AI | You are a helpful but sarcastic assistant |
| OLLAMA_MODEL | The model used by local Ollama server | llama3.1 |
| HUGGINGFACEHUB_MODEL | Hugging Face model | microsoft/Phi-3-mini-4k-instruct |
| HUGGINGFACEHUB_API_KEY | Hugging Face access token | |
| HUGGINGFACEHUB_ENDPOINT_URL | Hugging Face inference endpoint url | |
| Configuration variable | Description | Default value |
|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| SYSTEM_MESSAGE | System message that defines the behaviour of the AI | You are a helpful but sarcastic assistant |
| OLLAMA_MODEL | The model used by local Ollama server | llama3.1 |
| HUGGINGFACEHUB_MODEL | Hugging Face model | microsoft/Phi-3-mini-4k-instruct |
| HUGGINGFACEHUB_API_KEY | Hugging Face access token | |
| HUGGINGFACEHUB_ENDPOINT_URL | Hugging Face inference endpoint url | |
| DB_URL | Database to use. Supported configuration are:<br/>- leve empty for local in memory storage<br/>- `mongodb://xxx/xxx` for Mongodb | |

8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
mongodb:
image: mongo:8.0.0-rc19
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: superduper
MONGO_INITDB_ROOT_PASSWORD: SuperDuper12345HollaMollaLaaaaa
4 changes: 3 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
output: "standalone",
};

export default nextConfig;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@langchain/ollama": "^0.0.4",
"ai": "^3.3.16",
"langchain": "^0.2.16",
"mongodb": "^6.8.0",
"next": "14.2.6",
"prettier": "^3.3.3",
"react": "^18",
Expand Down
Loading
Loading