From 15203c123dff84685d5a9c57286bf35e7462f452 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:49:16 +0530 Subject: [PATCH 01/13] feat(docs): update search docs --- docs/API/SEARCH.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/API/SEARCH.md b/docs/API/SEARCH.md index d3391c9..714cbd8 100644 --- a/docs/API/SEARCH.md +++ b/docs/API/SEARCH.md @@ -6,7 +6,9 @@ Perplexica’s Search API makes it easy to use our AI-powered search engine. You ## Endpoint -### **POST** `/api/search` +### **POST** `http://localhost:3001/api/search` + +**Note**: Replace `3001` with any other port if you've changed the default PORT ### Request From 8902abdcee7a1f7fe964381f7afb9e31acfb6136 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:54:35 +0530 Subject: [PATCH 02/13] Update SEARCH.md --- docs/API/SEARCH.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/API/SEARCH.md b/docs/API/SEARCH.md index 714cbd8..56d34ce 100644 --- a/docs/API/SEARCH.md +++ b/docs/API/SEARCH.md @@ -28,7 +28,10 @@ The API accepts a JSON object in the request body, where you define the focus mo }, "focusMode": "webSearch", "query": "What is Perplexica", - "history": [] + "history": [ + ["human", "Hi, how are you?"], + ["assistant", "I am doing well, how can I help you today?"] + ] } ``` From e3488366c16ded6e8d60d3b77eb3ff2860db6026 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:56:19 +0530 Subject: [PATCH 03/13] Update SEARCH.md --- docs/API/SEARCH.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/API/SEARCH.md b/docs/API/SEARCH.md index 56d34ce..996a88b 100644 --- a/docs/API/SEARCH.md +++ b/docs/API/SEARCH.md @@ -37,7 +37,7 @@ The API accepts a JSON object in the request body, where you define the focus mo ### Request Parameters -- **`chatModel`** (object, optional): Defines the chat model to be used for the query. +- **`chatModel`** (object, optional): Defines the chat model to be used for the query. For model details you can send a GET request at `http://localhost:3001/api/models`. - `provider`: Specifies the provider for the chat model (e.g., `openai`, `ollama`). - `model`: The specific model from the chosen provider (e.g., `gpt-4o-mini`). @@ -45,7 +45,8 @@ The API accepts a JSON object in the request body, where you define the focus mo - `customOpenAIBaseURL`: If you’re using a custom OpenAI instance, provide the base URL. - `customOpenAIKey`: The API key for a custom OpenAI instance. -- **`embeddingModel`** (object, optional): Defines the embedding model for similarity-based searching. +- **`embeddingModel`** (object, optional): Defines the embedding model for similarity-based searching. For model details you can send a GET request at `http://localhost:3001/api/models`. + - `provider`: The provider for the embedding model (e.g., `openai`). - `model`: The specific embedding model (e.g., `text-embedding-3-large`). From 425a08432b29b96ed50378af0f87cba8272f1e03 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:37:05 +0530 Subject: [PATCH 04/13] feat(groq): add Llama 3.2 --- src/lib/providers/groq.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/lib/providers/groq.ts b/src/lib/providers/groq.ts index 6249267..69db4f7 100644 --- a/src/lib/providers/groq.ts +++ b/src/lib/providers/groq.ts @@ -9,6 +9,45 @@ export const loadGroqChatModels = async () => { try { const chatModels = { + 'llama-3.2-3b-preview': { + displayName: 'Llama 3.2 3B', + model: new ChatOpenAI( + { + openAIApiKey: groqApiKey, + modelName: 'llama-3.2-3b-preview', + temperature: 0.7, + }, + { + baseURL: 'https://api.groq.com/openai/v1', + }, + ), + }, + 'llama-3.2-11b-text-preview': { + displayName: 'Llama 3.2 11B Text', + model: new ChatOpenAI( + { + openAIApiKey: groqApiKey, + modelName: 'llama-3.2-11b-text-preview', + temperature: 0.7, + }, + { + baseURL: 'https://api.groq.com/openai/v1', + }, + ), + }, + 'llama-3.2-90b-text-preview': { + displayName: 'Llama 3.2 90B Text', + model: new ChatOpenAI( + { + openAIApiKey: groqApiKey, + modelName: 'llama-3.2-90b-text-preview', + temperature: 0.7, + }, + { + baseURL: 'https://api.groq.com/openai/v1', + }, + ), + }, 'llama-3.1-70b-versatile': { displayName: 'Llama 3.1 70B', model: new ChatOpenAI( From fc5e35b1b10c3e05303a457e64c9f84404dba748 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:59:40 +0530 Subject: [PATCH 05/13] feat(docker): add prebuilt images --- .github/workflows/docker-build.yaml | 46 +++++++++++++++++++++++++++++ backend.dockerfile | 1 - docker-compose.yaml | 2 ++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-build.yaml diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..90ccbe4 --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,46 @@ +name: Build & Push Docker Image + +on: + push: + branches: + - main + release: + types: [published] + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract version from release tag + if: github.event_name == 'release' + id: version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build and push Docker image + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: | + docker build -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:main . + docker build -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:main . + docker push itzcrazykns1337/perplexica-backend:main + docker push itzcrazykns1337/perplexica-frontend:main + + - name: Build and push release Docker image + if: github.event_name == 'release' + run: | + docker build -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} . + docker build -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} . + docker push itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} + docker push itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} \ No newline at end of file diff --git a/backend.dockerfile b/backend.dockerfile index 0169218..66de9dc 100644 --- a/backend.dockerfile +++ b/backend.dockerfile @@ -7,7 +7,6 @@ WORKDIR /home/perplexica COPY src /home/perplexica/src COPY tsconfig.json /home/perplexica/ -COPY config.toml /home/perplexica/ COPY drizzle.config.ts /home/perplexica/ COPY package.json /home/perplexica/ COPY yarn.lock /home/perplexica/ diff --git a/docker-compose.yaml b/docker-compose.yaml index d3892e5..ad61ec2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -15,6 +15,7 @@ services: dockerfile: backend.dockerfile args: - SEARXNG_API_URL=http://searxng:8080 + image: itzcrazykns1337/perplexica-backend:main depends_on: - searxng ports: @@ -35,6 +36,7 @@ services: args: - NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api - NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001 + image: itzcrazykns1337/perplexica-frontend:main depends_on: - perplexica-backend ports: From dcfe43ebda6b46b83eda33d2f8b049901d80df3e Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 2 Oct 2024 22:00:04 +0530 Subject: [PATCH 06/13] trigger build --- docs/API/SEARCH.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/API/SEARCH.md b/docs/API/SEARCH.md index 996a88b..a573021 100644 --- a/docs/API/SEARCH.md +++ b/docs/API/SEARCH.md @@ -47,7 +47,6 @@ The API accepts a JSON object in the request body, where you define the focus mo - **`embeddingModel`** (object, optional): Defines the embedding model for similarity-based searching. For model details you can send a GET request at `http://localhost:3001/api/models`. - - `provider`: The provider for the embedding model (e.g., `openai`). - `model`: The specific embedding model (e.g., `text-embedding-3-large`). From 4bba674134d2acce0d6a3d7f577125215a440546 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 2 Oct 2024 22:00:46 +0530 Subject: [PATCH 07/13] feat(build-workflow): update branch --- .github/workflows/docker-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 90ccbe4..ac855e1 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -3,7 +3,7 @@ name: Build & Push Docker Image on: push: branches: - - main + - master release: types: [published] From 1aaf172246e3900dc44ecfa0f8f34ce0a07893ed Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 2 Oct 2024 22:01:49 +0530 Subject: [PATCH 08/13] feat(build-workflow): update head --- .github/workflows/docker-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index ac855e1..6bf2c64 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -30,7 +30,7 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - name: Build and push Docker image - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + if: github.ref == 'refs/heads/master' && github.event_name == 'push' run: | docker build -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:main . docker build -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:main . From c233362e70aebf04fdfbb2da67e612ecc421ede3 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 2 Oct 2024 22:53:45 +0530 Subject: [PATCH 09/13] feat(dockerfile): specify default args --- .gitignore | 3 ++- app.dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a3dd5cc..8391d19 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ logs/ Thumbs.db # Db -db.sqlite \ No newline at end of file +db.sqlite +/searxng diff --git a/app.dockerfile b/app.dockerfile index 105cf86..8337171 100644 --- a/app.dockerfile +++ b/app.dockerfile @@ -1,7 +1,7 @@ FROM node:alpine -ARG NEXT_PUBLIC_WS_URL -ARG NEXT_PUBLIC_API_URL +ARG NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001 +ARG NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api ENV NEXT_PUBLIC_WS_URL=${NEXT_PUBLIC_WS_URL} ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} From 9f88d16ef1dbbc3100f6fa76dd7538ea6da04383 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 2 Oct 2024 22:54:00 +0530 Subject: [PATCH 10/13] feat(docker-compose): use env vars from compose --- backend.dockerfile | 3 --- docker-compose.yaml | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/backend.dockerfile b/backend.dockerfile index 66de9dc..70c30e8 100644 --- a/backend.dockerfile +++ b/backend.dockerfile @@ -1,8 +1,5 @@ FROM node:slim -ARG SEARXNG_API_URL -ENV SEARXNG_API_URL=${SEARXNG_API_URL} - WORKDIR /home/perplexica COPY src /home/perplexica/src diff --git a/docker-compose.yaml b/docker-compose.yaml index ad61ec2..46d82c6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,9 +13,9 @@ services: build: context: . dockerfile: backend.dockerfile - args: - - SEARXNG_API_URL=http://searxng:8080 image: itzcrazykns1337/perplexica-backend:main + environment: + - SEARXNG_API_URL=http://searxng:8080 depends_on: - searxng ports: From ae3fc5f80285b34d7e289498a9f6e1c61bef20aa Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Wed, 2 Oct 2024 22:54:16 +0530 Subject: [PATCH 11/13] feat(docs): modify updating docs --- docs/installation/UPDATING.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/installation/UPDATING.md b/docs/installation/UPDATING.md index df67775..031a3e8 100644 --- a/docs/installation/UPDATING.md +++ b/docs/installation/UPDATING.md @@ -10,15 +10,21 @@ To update Perplexica to the latest version, follow these steps: git clone https://github.com/ItzCrazyKns/Perplexica.git ``` -2. Navigate to the Project Directory +2. Navigate to the Project Directory. -3. Update and Rebuild Docker Containers: +3. Pull latest images from registry. ```bash -docker compose up -d --build +docker compose pull ``` -4. Once the command completes running go to http://localhost:3000 and verify the latest changes. +4. Update and Recreate containers. + +```bash +docker compose up -d +``` + +5. Once the command completes running go to http://localhost:3000 and verify the latest changes. ## For non Docker users From 66f1e19ce88eaf167f09f66bbd196eaa89a9ffa5 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:37:15 +0530 Subject: [PATCH 12/13] feat(image-build): use Docker buildx, publish multi arch images --- .github/workflows/docker-build.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 6bf2c64..63210ff 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -17,6 +17,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + with: + install: true - name: Log in to DockerHub uses: docker/login-action@v2 @@ -32,15 +34,13 @@ jobs: - name: Build and push Docker image if: github.ref == 'refs/heads/master' && github.event_name == 'push' run: | - docker build -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:main . - docker build -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:main . - docker push itzcrazykns1337/perplexica-backend:main - docker push itzcrazykns1337/perplexica-frontend:main + docker buildx create --use + docker buildx build --platform linux/amd64,linux/arm64 -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:main --push . + docker buildx build --platform linux/amd64,linux/arm64 -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:main --push . - name: Build and push release Docker image if: github.event_name == 'release' run: | - docker build -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} . - docker build -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} . - docker push itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} - docker push itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} \ No newline at end of file + docker buildx create --use + docker buildx build --platform linux/amd64,linux/arm64 -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} --push . + docker buildx build --platform linux/amd64,linux/arm64 -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} --push . \ No newline at end of file From 1680a1786e7e81122c36743d580a4caafe19612e Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:41:05 +0530 Subject: [PATCH 13/13] feat(image-build): improve build time by caching --- .github/workflows/docker-build.yaml | 40 +++++++++++++++++++++++------ app.dockerfile | 2 +- backend.dockerfile | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 63210ff..3cd9044 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -1,4 +1,4 @@ -name: Build & Push Docker Image +name: Build & Push Docker Images on: push: @@ -10,7 +10,9 @@ on: jobs: build-and-push: runs-on: ubuntu-latest - + strategy: + matrix: + service: [backend, app] steps: - name: Checkout code uses: actions/checkout@v3 @@ -31,16 +33,38 @@ jobs: id: version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - name: Build and push Docker image + - name: Build and push Docker image for ${{ matrix.service }} if: github.ref == 'refs/heads/master' && github.event_name == 'push' run: | docker buildx create --use - docker buildx build --platform linux/amd64,linux/arm64 -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:main --push . - docker buildx build --platform linux/amd64,linux/arm64 -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:main --push . + if [[ "${{ matrix.service }}" == "backend" ]]; then \ + DOCKERFILE=backend.dockerfile; \ + IMAGE_NAME=perplexica-backend; \ + else \ + DOCKERFILE=app.dockerfile; \ + IMAGE_NAME=perplexica-frontend; \ + fi + docker buildx build --platform linux/amd64,linux/arm64 \ + --cache-from=type=registry,ref=itzcrazykns1337/${IMAGE_NAME}:main \ + --cache-to=type=inline \ + -f $DOCKERFILE \ + -t itzcrazykns1337/${IMAGE_NAME}:main \ + --push . - - name: Build and push release Docker image + - name: Build and push release Docker image for ${{ matrix.service }} if: github.event_name == 'release' run: | docker buildx create --use - docker buildx build --platform linux/amd64,linux/arm64 -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} --push . - docker buildx build --platform linux/amd64,linux/arm64 -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} --push . \ No newline at end of file + if [[ "${{ matrix.service }}" == "backend" ]]; then \ + DOCKERFILE=backend.dockerfile; \ + IMAGE_NAME=perplexica-backend; \ + else \ + DOCKERFILE=app.dockerfile; \ + IMAGE_NAME=perplexica-frontend; \ + fi + docker buildx build --platform linux/amd64,linux/arm64 \ + --cache-from=type=registry,ref=itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }} \ + --cache-to=type=inline \ + -f $DOCKERFILE \ + -t itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }} \ + --push . diff --git a/app.dockerfile b/app.dockerfile index 8337171..ff1824d 100644 --- a/app.dockerfile +++ b/app.dockerfile @@ -9,7 +9,7 @@ WORKDIR /home/perplexica COPY ui /home/perplexica/ -RUN yarn install +RUN yarn install --frozen-lockfile RUN yarn build CMD ["yarn", "start"] \ No newline at end of file diff --git a/backend.dockerfile b/backend.dockerfile index 70c30e8..b8d0155 100644 --- a/backend.dockerfile +++ b/backend.dockerfile @@ -10,7 +10,7 @@ COPY yarn.lock /home/perplexica/ RUN mkdir /home/perplexica/data -RUN yarn install +RUN yarn install --frozen-lockfile RUN yarn build CMD ["yarn", "start"] \ No newline at end of file