Skip to content

Chatbot impl #295

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

Draft
wants to merge 54 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
0003897
Implement chatbot UI
piyushroshan Apr 19, 2024
8d71707
added llm chatbot service (#242)
dhruv-singhal-github Apr 20, 2024
7a12fc6
Llm chatbot (#243)
dhruv-singhal-github Apr 22, 2024
4d44d02
Integration
piyushroshan Apr 23, 2024
12c365e
Lint
piyushroshan Apr 23, 2024
ec8014f
Minor fixes
piyushroshan Apr 23, 2024
41f166d
Fix ssl issue
piyushroshan Apr 23, 2024
4f17fdb
Fix docker
piyushroshan Apr 23, 2024
055638f
Fix entrypoint
piyushroshan Apr 23, 2024
1e7be93
increase timeout
piyushroshan Apr 23, 2024
a927692
Implement helm
piyushroshan Apr 23, 2024
92efb5d
Merge branch 'chatbot' of github.com:OWASP/crAPI into chatbot
piyushroshan Apr 23, 2024
1374e2c
Fix entrypoint
piyushroshan Apr 23, 2024
48f1bf3
Store user state for chatbot
piyushroshan Apr 24, 2024
0b25ece
resolved segmentation fault error in chatbot (#245)
dhruv-singhal-github Apr 25, 2024
446512f
Add release workflow
piyushroshan Apr 28, 2024
23961d4
Instructions
piyushroshan Apr 28, 2024
da92874
Fix tag publish
piyushroshan Apr 28, 2024
c1faf3e
Strip tag prefix
piyushroshan Apr 28, 2024
f54777b
String tag prefix for docker tags
piyushroshan Apr 29, 2024
5322d14
Fix entrypoint.sh
piyushroshan Apr 29, 2024
e97a52f
Session based chat
piyushroshan Apr 30, 2024
daaa28b
Fix UI
piyushroshan Apr 30, 2024
6b46a58
Lint
piyushroshan Apr 30, 2024
da66cd7
Fix configmap
piyushroshan Apr 30, 2024
2e4fa9a
Update requirements
piyushroshan Apr 30, 2024
61477a6
Fix dockerfile
piyushroshan Apr 30, 2024
5642759
Fix UX
piyushroshan Apr 30, 2024
186451d
Seperate prompts
piyushroshan May 2, 2024
c66bc29
Change to ChatOpenAI
piyushroshan May 2, 2024
9afee6a
Change to ChatOpenAI
piyushroshan May 2, 2024
199f0d3
Return messages
piyushroshan May 2, 2024
315b10a
Save chat history
piyushroshan May 2, 2024
9d63c38
Cleanup
piyushroshan May 2, 2024
b70a131
Cleanup
piyushroshan May 2, 2024
895c01a
Preserve X-Forwarded-For
piyushroshan May 2, 2024
d1cbf26
Add mongo dependency for chatbot
piyushroshan May 2, 2024
eac14c9
Use old turbo model
piyushroshan May 2, 2024
b13ce4d
FSession logs not clearer debug
piyushroshan May 2, 2024
08344a8
Add ssn
piyushroshan May 3, 2024
03b8832
Merge remote-tracking branch 'origin/develop' into chatbot
piyushroshan May 12, 2024
4b78d7b
Merge branch 'develop' into chatbot
piyushroshan May 17, 2024
57c81db
Merge branch 'develop' into chatbot
piyushroshan May 19, 2024
263e45e
Update values
piyushroshan May 28, 2024
e38cb66
Fix gateway service health
piyushroshan May 28, 2024
0bf05d9
Merge branch 'develop' into chatbot
piyushroshan May 4, 2025
ae57db0
Chatbot typescript
piyushroshan May 4, 2025
4a9201a
Upgrade packages
piyushroshan May 4, 2025
98f7451
Dummy commit
piyushroshan May 4, 2025
6393fe7
Lint
piyushroshan May 4, 2025
f3745f6
lint
piyushroshan May 4, 2025
717bc76
Reduce max mem
piyushroshan May 4, 2025
2dbe0bf
Update chatbot
piyushroshan May 5, 2025
3a9b002
Update chatbot
piyushroshan May 5, 2025
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
15 changes: 14 additions & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
with:
strip_tag_prefix: 'v'

- name: Current branch name
run: |
Expand All @@ -46,7 +48,7 @@ jobs:
if: steps.branch-name.outputs.is_tag == 'true'
run: |
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
echo "TAG_LATEST=latest" >> ${GITHUB_ENV}
echo "TAG_LATEST=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}

- name: Running on a branch and merge.
if: steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch != 'main'
Expand Down Expand Up @@ -96,6 +98,17 @@ jobs:
cache-from: type=gha,scope=workshop-service
cache-to: type=gha,mode=max,scope=workshop-service

- name: Build crapi-chatbot image
uses: docker/build-push-action@v3
with:
context: ./services/chatbot
tags: crapi/crapi-chatbot:${{ env.TAG_LATEST }},crapi/crapi-chatbot:${{ env.TAG_NAME }}
push: false
load: true
platforms: linux/amd64
cache-from: type=gha,scope==chatbot-service
cache-to: type=gha,mode=max,scope=chatbot-service

- name: Build crapi-community image
uses: docker/build-push-action@v3
with:
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
with:
strip_tag_prefix: 'v'

- name: Current branch name
run: |
Expand All @@ -48,7 +50,7 @@ jobs:
if: steps.branch-name.outputs.is_tag == 'true'
run: |
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
echo "TAG_LATEST=latest" >> ${GITHUB_ENV}
echo "TAG_LATEST=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}

- name: Running on a branch and merge.
if: steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch != 'main'
Expand Down Expand Up @@ -102,6 +104,16 @@ jobs:
cache-from: type=gha,scope=workshop-service
cache-to: type=gha,mode=max,scope=workshop-service

- name: Build crapi-chatbot all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/chatbot
tags: crapi/crapi-chatbot:${{ env.TAG_LATEST }},crapi/crapi-chatbot:${{ env.TAG_NAME }}
platforms: ${{ env.PLATFORMS }}
push: true
cache-from: type=gha,scope=chatbot-service
cache-to: type=gha,mode=max,scope=chatbot-service

- name: Build crapi-community all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
Expand Down
225 changes: 225 additions & 0 deletions .github/workflows/workflow-multiarch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
name: Release Publish
on: workflow_dispatch

jobs:
build-context:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
build:
needs: build-context
strategy:
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
arch_alias: 'amd64'
- runner: ubuntu-latest-arm64
platform: linux/arm64
arch_alias: 'arm64'
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Env seen prerun
run: env

- name: Get branch metadata
id: branch-name
uses: tj-actions/branch-names@v8

- name: Current tag name
run: |
echo "Tag if exist: ${{ steps.branch-name.outputs.tag }}"

- name: If not a tag, terminate the workflow
if: steps.branch-name.outputs.is_tag != 'true'
run: exit 1

- name: Running on a tag.
run: |
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" > tag_name.txt

# Archive the tag name
- name: Archive tag name
uses: actions/upload-artifact@v2
with:
name: tag_name
path: tag_name.txt

# setup Docker build action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build crapi-identity all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/identity
tags: crapi/crapi-identity:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
platforms: ${{ matrix.platform }}
push: true
cache-from: type=gha,scope=identity-service
cache-to: type=gha,mode=max,scope=identity-service

- name: Build crapi-workshop all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/workshop
tags: crapi/crapi-workshop:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
platforms: ${{ matrix.platform }}
push: true
cache-from: type=gha,scope=workshop-service
cache-to: type=gha,mode=max,scope=workshop-service

- name: Build crapi-chatbot all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/chatbot
tags: crapi/crapi-chatbot:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
platforms: ${{ matrix.platform }}
push: true
cache-from: type=gha,scope=chatbot-service
cache-to: type=gha,mode=max,scope=chatbot-service

- name: Build crapi-community all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/community
tags: crapi/crapi-community:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
platforms: ${{ matrix.platform }}
push: true
cache-from: type=gha,scope=community-service
cache-to: type=gha,mode=max,scope=community-service

- name: Build crapi-web all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/web
tags: crapi/crapi-web:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
platforms: ${{ matrix.platform }}
push: true
cache-from: type=gha,scope=web-service
cache-to: type=gha,mode=max,scope=web-service

- name: Build gateway-service all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/gateway-service
tags: crapi/gateway-service:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
platforms: ${{ matrix.platform }}
push: true
cache-from: type=gha,scope=gateway-service
cache-to: type=gha,mode=max,scope=gateway-service

- name: Build mailhog all platforms and push to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./services/mailhog
tags: crapi/mailhog:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
platforms: ${{ matrix.platform }}
push: true
cache-from: type=gha,scope=mailhog-service
cache-to: type=gha,mode=max,scope=mailhog-service

publish-manifests:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download tag name
uses: actions/download-artifact@v2
with:
name: tag_name
path: .

- name: Read tag name
id: tag_name
run: |
echo "TAG_NAME=$(cat tag_name.txt)" >> $GITHUB_ENV

- name: Create and push manifest images for crapi-identity
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
crapi/crapi-identity:${{ env.TAG_NAME }}-amd64
crapi/crapi-identity:${{ env.TAG_NAME }}-arm64
outputs: |
crapi/crapi-identity:${{ env.TAG_NAME }}
push: true

- name: Create and push manifest images for crapi-workshop
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
crapi/crapi-workshop:${{ env.TAG_NAME }}-amd64
crapi/crapi-workshop:${{ env.TAG_NAME }}-arm64
outputs: |
crapi/crapi-workshop:${{ env.TAG_NAME }}
push: true

- name: Create and push manifest images for crapi-chatbot
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
crapi/crapi-chatbot:${{ env.TAG_NAME }}-amd64
crapi/crapi-chatbot:${{ env.TAG_NAME }}-arm64
outputs: |
crapi/crapi-chatbot:${{ env.TAG_NAME }}
push: true

- name: Create and push manifest images for crapi-community
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
crapi/crapi-community:${{ env.TAG_NAME }}-amd64
crapi/crapi-community:${{ env.TAG_NAME }}-arm64
outputs: |
crapi/crapi-community:${{ env.TAG_NAME }}
push: true

- name: Create and push manifest images for crapi-web
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
crapi/crapi-web:${{ env.TAG_NAME }}-amd64
crapi/crapi-web:${{ env.TAG_NAME }}-arm64
outputs: |
crapi/crapi-web:${{ env.TAG_NAME }}
push: true

- name: Create and push manifest images for gateway-service
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
crapi/gateway-service:${{ env.TAG_NAME }}-amd64
crapi/gateway-service:${{ env.TAG_NAME }}-arm64
outputs: |
crapi/gateway-service:${{ env.TAG_NAME }}
push: true

- name: Create and push manifest images for mailhog
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
crapi/mailhog:${{ env.TAG_NAME }}-amd64
crapi/mailhog:${{ env.TAG_NAME }}-arm64
outputs: |
crapi/mailhog:${{ env.TAG_NAME }}
push: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ deploy/vagrant/.vagrant
.secrets
.vscode/
*.local
services/chatbot/db
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,5 @@ To know more about challenges in crAPI. Visit [challenges]
## Troubleshooting guide for general issues while installing and running crAPI
If you need any help with installing and running crAPI you can check out this guide: [Troubleshooting guide crAPI](https://github.com/OWASP/crAPI/blob/main/docs/troubleshooting.md). If this doesn't solve your problem, please create an issue in Github Issues.
1 change: 1 addition & 0 deletions deploy/docker/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
IDENTITY_SERVER_PORT=8080
COMMUNITY_SERVER_PORT=8087
WORKSHOP_SERVER_PORT=8000
CHATBOT_SERVER_PORT=5002
ENABLE_SHELL_INJECTION=false
ENABLE_LOG4J=false
LISTEN_IP="127.0.0.1"
Expand Down
24 changes: 24 additions & 0 deletions deploy/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,29 @@ services:
cpus: '0.3'
memory: 128M

crapi-chatbot:
container_name: crapi-chatbot
image: crapi/crapi-chatbot:${VERSION:-latest}
environment:
- TLS_ENABLED=${TLS_ENABLED:-false}
- SERVER_PORT=${CHATBOT_SERVER_PORT:-5002}
- DB_NAME=crapi
- DB_USER=admin
- DB_PASSWORD=crapisecretpassword
- DB_HOST=postgresdb
- DB_PORT=5432
- MONGO_DB_HOST=mongodb
- MONGO_DB_PORT=27017
- MONGO_DB_USER=admin
- MONGO_DB_PASSWORD=crapisecretpassword
- MONGO_DB_NAME=crapi
# - CHATBOT_OPENAI_API_KEY=
depends_on:
mongodb:
condition: service_healthy
# ports:
# - "${LISTEN_IP:-127.0.0.1}:5002:5002"

crapi-web:
container_name: crapi-web
image: crapi/crapi-web:${VERSION:-latest}
Expand All @@ -162,6 +185,7 @@ services:
- COMMUNITY_SERVICE=crapi-community:${COMMUNITY_SERVER_PORT:-8087}
- IDENTITY_SERVICE=crapi-identity:${IDENTITY_SERVER_PORT:-8080}
- WORKSHOP_SERVICE=crapi-workshop:${WORKSHOP_SERVER_PORT:-8000}
- CHATBOT_SERVICE=crapi-chatbot:${CHATBOT_SERVER_PORT:-5002}
- MAILHOG_WEB_SERVICE=mailhog:8025
- TLS_ENABLED=${TLS_ENABLED:-false}
depends_on:
Expand Down
1 change: 1 addition & 0 deletions deploy/docker/scripts/load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ docker load -i gateway-service.tar
docker load -i crapi-identity.tar
docker load -i crapi-community.tar
docker load -i crapi-workshop.tar
docker load -i crapi-chatbot.tar
docker load -i crapi-web.tar
docker load -i postgres.tar
docker load -i mongo.tar
1 change: 1 addition & 0 deletions deploy/docker/scripts/save.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ docker save crapi/gateway-service:develop -o gateway-service.tar
docker save crapi/crapi-identity:develop -o crapi-identity.tar
docker save crapi/crapi-community:develop -o crapi-community.tar
docker save crapi/crapi-workshop:develop -o crapi-workshop.tar
docker save crapi/crapi-chatbot:develop -o crapi-chatbot.tar
docker save crapi/crapi-web:develop -o crapi-web.tar
docker save postgres:14 -o postgres.tar
docker save mongo:4.4 -o mongo.tar
4 changes: 2 additions & 2 deletions deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.4
version: 0.1.5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: develop
appVersion: chatbot
Loading
Loading