diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..fe6d494
--- /dev/null
+++ b/.env.example
@@ -0,0 +1 @@
+VITE_BASE_URL_PROD=
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
new file mode 100644
index 0000000..4020bcb
--- /dev/null
+++ b/.eslintrc.cjs
@@ -0,0 +1,14 @@
+module.exports = {
+ env: { browser: true, es2020: true },
+ extends: [
+ 'eslint:recommended',
+ 'plugin:@typescript-eslint/recommended',
+ 'plugin:react-hooks/recommended',
+ ],
+ parser: '@typescript-eslint/parser',
+ parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
+ plugins: ['react-refresh'],
+ rules: {
+ 'react-refresh/only-export-components': 'warn',
+ },
+}
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..a033c58
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,4 @@
+# These are supported funding model platforms
+
+github: [Nasfame]
+
diff --git a/.github/archivedworkflow/deploy-pages.yml b/.github/archivedworkflow/deploy-pages.yml
new file mode 100644
index 0000000..4c24ed5
--- /dev/null
+++ b/.github/archivedworkflow/deploy-pages.yml
@@ -0,0 +1,48 @@
+name: Deploy to GitHub Pages
+
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - '.github/workflows/deploy.yml'
+ pull_request:
+ branches:
+ - main
+ workflow_dispatch:
+
+env:
+ VITE_BASE_URL_PROD: "https://34.199.237.66"
+
+permissions:
+ contents: write
+ pages: write
+ id-token: write
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+# defaults:
+# run:
+# working-directory:
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: 18
+
+ - name: Install dependencies
+ run: npm install --include=dev
+
+ - name: Build static assets
+ run: npm run build
+
+ - name: Deploy to GitHub Pages
+ uses: peaceiris/actions-gh-pages@v3
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: ./build
diff --git a/.github/archivedworkflow/deploy.yml b/.github/archivedworkflow/deploy.yml
new file mode 100644
index 0000000..2dae08a
--- /dev/null
+++ b/.github/archivedworkflow/deploy.yml
@@ -0,0 +1,49 @@
+name: Deploy to GitHub Pages
+
+on:
+ push:
+ branches:
+ - main # Adjust the branch name as per your project setup
+ pull_request:
+ branches: [ "main" ]
+ workflow_dispatch:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: 18
+
+ - name: Get yarn cache
+ id: yarn-cache
+ run: echo "YARN_CACHE_DIR=$(yarn cache dir)" >> "${GITHUB_OUTPUT}"
+
+ - name: Cache dependencies
+ uses: actions/cache@v3
+ with:
+ path: ${{ steps.yarn-cache.outputs.YARN_CACHE_DIR }}
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-yarn-
+
+ - name: Install dependencies
+ run: npm install # or yarn install
+
+ - name: Build React app
+ run: npm run build # or yarn build
+
+ - name: Deploy to GitHub Pages
+ uses: peaceiris/actions-gh-pages@v3
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: ./build
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..fc1e78d
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,62 @@
+name: Deploy to GitHub Pages
+
+on:
+ push:
+ branches:
+ - main # Adjust the branch name as per your project setup
+ paths:
+ - '.github/workflows/deploy.yml'
+ pull_request:
+ branches: [ "main" ]
+ workflow_dispatch:
+
+env:
+ VITE_BASE_URL_PROD: "http://34.199.237.66"
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+
+permissions:
+ contents: write
+ pages: write
+ id-token: write
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ # defaults:
+ # run:
+ # working-directory:
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: 18
+
+ - name: Get npm cache
+ id: npm-cache
+ run: echo "NPM_CACHE_DIR=$(pwd)/node_modules" >> "${GITHUB_OUTPUT}"
+
+ - name: Cache dependencies
+ uses: actions/cache@v3
+ with:
+ path: ${{ steps.npm-cache.outputs.NPM_CACHE_DIR }}
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**package.json') }}
+ restore-keys: |
+ ${{ runner.os }}-npm-${{ hashFiles('**package.json') }}
+
+ - name: Install dependencies
+ run: npm install --include=dev
+
+ - name: Deploy React to GitHub Pages
+ uses: bitovi/github-actions-react-to-ghp@v1.2.0
+ with:
+ checkout: false
+ # Specifies the path of the static assets after building
+ path: ${{ github.workspace }}/build
+ # Specifies the command to run after npm ci for the build
+ build_command: npm run build
diff --git a/.gitignore b/.gitignore
index ab97a8c..af728fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,32 @@ modern.jsonp
resources/sass/.sass-cache/
resources/.arch-internal-preview.css
.arch-internal-preview.css
+node_modules/
+
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+dist
+dist-ssr
+*.local
+package-lock.json
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
+.env
+
+.env-*
diff --git a/README.md b/README.md
index 51b73c3..da13e0f 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,40 @@
-# AI-Chats
-Lets build something cooler that chatgpt
+# AI Chats
+
+
+
+AI Chats is an AI-powered chatbot that can simulate human-like conversation and assist with various tasks. It is built using natural language processing and machine learning techniques to understand and respond to user queries.
+
+## Features
+
+- Natural language understanding and response generation
+- Task assistance such as scheduling appointments and answering FAQs
+- Learning and improvement over time
+
+## Inspiration
+
+The inspiration behind AI Chats was to explore the potential of artificial intelligence in enhancing human interaction. The goal was to create a chatbot that could provide valuable assistance and simulate human-like conversation.
+
+## How It Works
+
+AI Chats is built using Python, Golang, Node.js, and React. It leverages openAI for natural language processing and pinecone for efficient search and retrieval of responses. The chatbot is trained on a large dataset of conversations to improve its understanding and response accuracy.
+
+## Challenges
+
+One of the main challenges faced during development was improving the chatbot's accuracy and ability to understand complex queries. Extensive testing and fine-tuning were done to ensure relevant and helpful responses.
+
+## Accomplishments
+
+The team is proud to have created a chatbot that can understand natural language and provide helpful responses. The user-friendly interface makes it easy for users to interact with the chatbot.
+
+## Future Plans
+
+In the future, the team plans to integrate AI Chats with other platforms and services to enhance its functionality. They also aim to improve its ability to handle complex queries and provide more personalized responses.
+
+## Try It Out
+
+Visit [AI Chats](http://aichats.surge.sh) to try out the chatbot and experience its capabilities.
+
+## Getting Started
+
+To get started with the project, follow the instructions in the [GitHub repository](https://github.com/aichats/aichats).
+
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..49998c9
--- /dev/null
+++ b/index.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AIChats
+
+
+
+
+
+
diff --git a/index.ts b/index.ts
new file mode 100644
index 0000000..e69de29
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..b97bae3
--- /dev/null
+++ b/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "frontend",
+ "private": false,
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "tsc && vite build",
+ "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
+ "preview": "vite preview",
+ "deploy": "VITE_BASE_URL_PROD=https://34.199.237.66 npm run build && surge build aichats.surge.sh ",
+ "gh": "gh-pages -d build"
+ },
+ "dependencies": {
+ "@tailwindcss/forms": "^0.5.3",
+ "axios": "^1.4.0",
+ "firebase": "^9.23.0",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "react-icons": "^4.10.1",
+ "react-query": "^3.39.3",
+ "react-scroll-to-bottom": "^4.2.0",
+ "zustand": "^4.3.8"
+ },
+ "devDependencies": {
+ "@types/react": "^18.0.37",
+ "@types/react-dom": "^18.0.11",
+ "@types/react-scroll-to-bottom": "^4.2.1",
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
+ "@typescript-eslint/parser": "^5.59.0",
+ "@vitejs/plugin-react": "^4.0.0",
+ "autoprefixer": "^10.4.14",
+ "eslint": "^8.38.0",
+ "eslint-plugin-react-hooks": "^4.6.0",
+ "eslint-plugin-react-refresh": "^0.3.4",
+ "postcss": "^8.4.24",
+ "tailwindcss": "^3.3.2",
+ "typescript": "^5.0.2",
+ "vite": "^4.3.9",
+ "gh-pages": "^3.2.3"
+ }
+}
diff --git a/postcss.config.js b/postcss.config.js
new file mode 100644
index 0000000..2e7af2b
--- /dev/null
+++ b/postcss.config.js
@@ -0,0 +1,6 @@
+export default {
+ plugins: {
+ tailwindcss: {},
+ autoprefixer: {},
+ },
+}
diff --git a/postman/collections/AIChats.json b/postman/collections/AIChats.json
new file mode 100644
index 0000000..44101b7
--- /dev/null
+++ b/postman/collections/AIChats.json
@@ -0,0 +1,843 @@
+{
+ "info": {
+ "_postman_id": "620c2f77-37f6-4c46-826d-d025413fe3ef",
+ "name": "AIChats",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
+ "_uid": "11058592-620c2f77-37f6-4c46-826d-d025413fe3ef"
+ },
+ "item": [
+ {
+ "name": "Home",
+ "id": "565b457f-35d7-46b7-8219-7a9633ce9513",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}",
+ "host": [
+ "{{u}}"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "d94918d8-3cad-4a98-a6ef-4e37077a278e",
+ "name": "Root",
+ "originalRequest": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}",
+ "host": [
+ "{{u}}"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Sat, 24 Jun 2023 10:34:20 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "27"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"message\": \"AI Chat is up\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Health",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "5abbcf93-f76a-4482-ac82-376b1405ea38",
+ "exec": [
+ "let body = pm.response.json()",
+ "",
+ "",
+ "pm.test(\"Status code is 200\", function () {",
+ " pm.response.to.have.status(200);",
+ "});",
+ "",
+ "",
+ "pm.test(\"Health\", function () {",
+ " pm.expect(body.status).to.eql(\"ok\")",
+ "});"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "id": "14643d82-bff4-4fa3-903c-bc1fe334d6dc",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}/health",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "health"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "a2d4a2a7-597b-41ac-b5d1-1db7ed4c8e28",
+ "name": "Root",
+ "originalRequest": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}",
+ "host": [
+ "{{u}}"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Sat, 24 Jun 2023 10:34:20 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "27"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"message\": \"AI Chat is up\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Cors",
+ "id": "03e886c8-b8b4-4cc0-9703-a8b2bf9dfdbe",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Origin",
+ "value": "{{u}}"
+ },
+ {
+ "key": "Access-Control-Request-Method",
+ "value": "GET"
+ },
+ {
+ "key": "Access-Control-Request-Headers",
+ "value": "X-Requested-With"
+ },
+ {
+ "key": "Referer",
+ "value": "http://localhost"
+ },
+ {
+ "key": "User-Agent",
+ "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
+ }
+ ],
+ "url": {
+ "raw": "{{u}}",
+ "host": [
+ "{{u}}"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Chat Create",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "a14cdd1c-7d0d-412a-8213-df2f36c7497f",
+ "exec": [
+ "function sendRequest(id,s){",
+ " console.log(id,s)",
+ "}",
+ "",
+ "sendRequest(1,\"apple\")",
+ "sendRequest(2,\"orange\")",
+ "",
+ "const {sender,message,chat_id} = pm.response.json()",
+ "",
+ "console.log(chat_id,message)",
+ "",
+ "pm.environment.set(\"chat_id\",chat_id)",
+ "",
+ ""
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "id": "688fa14e-7795-410d-8e01-da7fb969c21d",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"I am Hiro, I am a golang engineer.\",\n \"chat_id\": null\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "f385c9b9-a25c-4927-b772-820258f7e8bb",
+ "name": "Chat Create v0",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"Hello, how are you?\",\n \"chat_id\": null\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Sun, 25 Jun 2023 01:28:24 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "512"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"IndyStar\\n\\nWith the Joe Biden and Kamala Harris win looming, one can only hope that many minds will change. It appears that we may not know the actual outcome of this election for a while yet, and for many, that is concerning. What might be more concerning, however, is that this election has furthered the divide between many Americans.\\n\\nHow will we come together as a nation after such a heated and divisive election?\\n\\nThe battleground states of Wisconsin, Arizona\",\n \"chat_id\": 1\n}"
+ },
+ {
+ "id": "f1564be5-8399-4a0d-a47d-c1107ba92242",
+ "name": "Chat Create v0",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"Two people have pleaded guilty and been sent to prison; the law has been clarified; a huge deterrent message has been delivered.\",\n \"chat_id\": 1\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Sun, 25 Jun 2023 23:18:00 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "478"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"Starlight\\n\\nOne fine day, I looked up and saw the starlight in the sky. All of the stars were twinkling and it was such a beautiful sight. I felt like I could reach out and touch them and I felt so small and insignificant. The starlight had been there for millions of years, but no one had paid attention to it until that moment. I could feel the power of the universe in that moment, and it made me feel so connected to everything. I\",\n \"chat_id\": \"1\"\n}"
+ },
+ {
+ "id": "84f0b793-608b-4006-86eb-aaa602e0f86c",
+ "name": "Chat Create v1",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"I am Hiro, I am a golang engineer.\",\n \"chat_id\": null\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v1"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:54:58 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "209"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \" Hi Hiro, it's nice to meet you. I'm an AI and I'm interested in learning more about Golang engineering. Can you tell me more about it?\",\n \"chat_id\": \"03c5d673753743c8b38f30da9b58f802\"\n}"
+ },
+ {
+ "id": "8d368e6f-0fbd-45a6-b48c-8383d985b600",
+ "name": "Chat Create v2",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"I am Hiro, I am a golang engineer.\",\n \"chat_id\": null\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 18:19:02 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "113"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"Hello Hiro, how can I assist you today?\",\n \"chat_id\": \"4388081e510e4307b56b4957a1dfe7fa\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "PDF Upload",
+ "id": "e077604c-bc53-4ce6-a465-07479da8dc52",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "PUT",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "file",
+ "type": "file",
+ "src": "/Users/hiro/aiFame/aichatsback/testdata/go.pdf"
+ },
+ {
+ "key": "filename",
+ "value": "",
+ "type": "text",
+ "disabled": true
+ }
+ ]
+ },
+ "url": {
+ "raw": "{{u}}/chat/:id/upload/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ ":id",
+ "upload",
+ "v2"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "6be597c8-2cc6-47c3-89bb-753087fbefb6",
+ "name": "PDF Upload v0",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "file",
+ "type": "file",
+ "src": [
+ "/Users/hiro/aiFame/aichatsback/testdata/Hiro Hamada LW Certificate_ Python.pdf"
+ ]
+ }
+ ]
+ },
+ "url": {
+ "raw": "{{u}}/chat/:id/upload",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ ":id",
+ "upload"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "\"\""
+ }
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Sat, 24 Jun 2023 14:27:42 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "47"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"message\": \"Uploaded successfully\",\n \"chat_id\": 1\n}"
+ },
+ {
+ "id": "2ad73d57-691a-4af2-93c2-9d4634153c77",
+ "name": "PDF Upload v1 Doesnot support inference to chat",
+ "originalRequest": {
+ "method": "PUT",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "file",
+ "type": "file",
+ "src": [
+ "/Users/hiro/aiFame/aichatsback/testdata/Hiro Hamada LW Certificate_ Python.pdf"
+ ]
+ }
+ ]
+ },
+ "url": {
+ "raw": "{{u}}/chat/:id/upload/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ ":id",
+ "upload",
+ "v1"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:51:45 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "95"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"uploaded successfully\",\n \"chat_id\": \"6bf57d6585cb4a3e85078989bf569051\"\n}"
+ },
+ {
+ "id": "1236d7dc-2342-4a5a-9a96-298846ec5d21",
+ "name": "PDF Upload v1.1",
+ "originalRequest": {
+ "method": "PUT",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "file",
+ "type": "file",
+ "src": [
+ "/Users/hiro/aiFame/aichatsback/testdata/prompt.txt"
+ ]
+ },
+ {
+ "key": "filename",
+ "value": "",
+ "type": "text",
+ "disabled": true
+ }
+ ]
+ },
+ "url": {
+ "raw": "{{u}}/chat/:id/upload/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ ":id",
+ "upload",
+ "v1"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "status": "Bad Request",
+ "code": 400,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 19:40:24 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "113"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"error\": \"Only pdf files are supported currently\",\n \"chat_id\": \"3bf5cf7f40564a068db77a89707c5887\",\n \"status_code\": 400\n}"
+ },
+ {
+ "id": "bcd52488-d6aa-4def-be04-189c6dc47645",
+ "name": "PDF Upload v2",
+ "originalRequest": {
+ "method": "PUT",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "file",
+ "type": "file",
+ "src": [
+ "/Users/hiro/aiFame/aichatsback/testdata/prompt.txt"
+ ]
+ },
+ {
+ "key": "filename",
+ "value": "",
+ "type": "text",
+ "disabled": true
+ }
+ ]
+ },
+ "url": {
+ "raw": "{{u}}/chat/:id/upload/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ ":id",
+ "upload",
+ "v2"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 19:41:26 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "113"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"error\": \"Only pdf files are supported currently\",\n \"chat_id\": \"3bf5cf7f40564a068db77a89707c5887\",\n \"status_code\": 400\n}"
+ }
+ ]
+ },
+ {
+ "name": "Healthcheck http",
+ "id": "86bdbcf5-20bb-4a79-b338-3b4945081c50",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://34.199.237.66",
+ "protocol": "http",
+ "host": [
+ "34",
+ "199",
+ "237",
+ "66"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Healthcheck https",
+ "id": "f9f5650d-9571-4248-a9c1-d87e2a73682c",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}",
+ "host": [
+ "{{u}}"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Chat",
+ "id": "9244d66f-318f-4f05-9af2-ea03602d3292",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}/chat/v2/:id",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2",
+ ":id"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Create Chat",
+ "id": "77babde9-e95f-4c05-979a-1fa3114ade85",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"Which go version is used in the pdf?\",\n \"chat_id\": \"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/postman/collections/Conversation.json b/postman/collections/Conversation.json
new file mode 100644
index 0000000..942f478
--- /dev/null
+++ b/postman/collections/Conversation.json
@@ -0,0 +1,963 @@
+{
+ "info": {
+ "_postman_id": "1cb8b832-1152-4301-905d-88e0fa9dca34",
+ "name": "Conversation",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
+ "_uid": "11058592-1cb8b832-1152-4301-905d-88e0fa9dca34"
+ },
+ "item": [
+ {
+ "name": "I am Hiro",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "a2e61596-2b6d-4892-963a-dc872bdef10f",
+ "exec": [
+ "const {sender,message,chat_id} = pm.response.json()",
+ "",
+ "console.log(chat_id,message)",
+ "",
+ "pm.environment.set(\"chat_id\",chat_id)",
+ "",
+ ""
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "id": "1d603a22-477d-4f07-a221-181f30a71532",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"Hi i am Hiro,Hello, how are you?\",\n \"chat_id\":null\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "0a89f40b-8a83-4984-bcaf-25cc12a5434c",
+ "name": "I am Hiro v1",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"Hi i am Hiro,Hello, how are you?\",\n \"chat_id\":null\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v1"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:48:20 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "115"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \" Hi Hiro, I'm doing great! How about you?\",\n \"chat_id\": \"6bf57d6585cb4a3e85078989bf569051\"\n}"
+ },
+ {
+ "id": "02e8c7a0-396c-48b1-b503-0d0f18c477f2",
+ "name": "I am Hiro v2",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"Hi i am Hiro,Hello, how are you?\",\n \"chat_id\":null\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 18:19:20 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "240"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"Hello Hiro, I'm an AI language model, so I don't have feelings in the way humans do, but I'm here to help you with any questions you have. How can I assist you today?\",\n \"chat_id\": \"b8c4097d735f4d63ad29422c966d6587\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Conversation Update",
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "id": "aca4a26f-99e6-445a-bc33-9b7e464630d1",
+ "exec": [
+ "console.log(\"chat_id\",pm.environment.get(\"chat_id\"))"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "id": "0cf06957-6cfd-4a25-a9e0-82f03c702eb1",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"who is Hiro?\",\n \"chat_id\": \"{{chat_id}}\"\n} ",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "a7cf5fb0-ad62-4536-aed0-a963ab365d57",
+ "name": "Conversation Update v1",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"who is Hiro?\",\n \"chat_id\": \"{{chat_id}}\"\n} ",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v1"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:48:32 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "125"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \" Hiro is you! You just introduced yourself as Hiro.\",\n \"chat_id\": \"6bf57d6585cb4a3e85078989bf569051\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Chat Get ID",
+ "id": "7ecf06d7-fb5f-4620-9a3b-f98b7df84c82",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}/chat/v2/:id",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2",
+ ":id"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "0a8eef87-8b65-4912-80ec-bc03c8b404ed",
+ "name": "Chat Get ID",
+ "originalRequest": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}/chat/v1/:id",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v1",
+ ":id"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:47:36 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "594"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"total\": 4,\n \"msgs\": [\n {\n \"sender\": \"user\",\n \"message\": \"I am Hiro, I am a golang engineer.\",\n \"chat_id\": \"73b3df71685046e696542fd5cd9d74e1\"\n },\n {\n \"sender\": \"bot\",\n \"message\": \" Hi Hiro, I'm an AI. It's nice to meet you. I'm impressed that you are a golang engineer. What do you like most about working with golang?\",\n \"chat_id\": \"73b3df71685046e696542fd5cd9d74e1\"\n },\n {\n \"sender\": \"user\",\n \"message\": \"who is Hiro?\",\n \"chat_id\": \"73b3df71685046e696542fd5cd9d74e1\"\n },\n {\n \"sender\": \"bot\",\n \"message\": \" Hiro is the name you just introduced yourself with. You said you are a golang engineer.\",\n \"chat_id\": \"73b3df71685046e696542fd5cd9d74e1\"\n }\n ]\n}"
+ },
+ {
+ "id": "774de809-6f4f-4ee1-a4d0-949cb83b9a67",
+ "name": "Chat Get ID",
+ "originalRequest": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{u}}/chat/v2/:id",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2",
+ ":id"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Wed, 28 Jun 2023 11:49:32 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "549"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"total\": 4,\n \"msgs\": [\n {\n \"sender\": \"user\",\n \"message\": \"Hi i am Hiro,Hello, how are you?\",\n \"chat_id\": \"a455c7bfa34646a5a5baf43516fcdae2\"\n },\n {\n \"sender\": \"bot\",\n \"message\": \"Hello Hiro, I'm an AI assistant, so I don't have feelings. But I'm here to help you. How can I assist you today?\",\n \"chat_id\": \"a455c7bfa34646a5a5baf43516fcdae2\"\n },\n {\n \"sender\": \"user\",\n \"message\": \"who is Hiro?\",\n \"chat_id\": \"a455c7bfa34646a5a5baf43516fcdae2\"\n },\n {\n \"sender\": \"bot\",\n \"message\": \"I'm sorry, but I don't have enough information to answer that question.\",\n \"chat_id\": \"a455c7bfa34646a5a5baf43516fcdae2\"\n }\n ]\n}"
+ }
+ ]
+ },
+ {
+ "name": "I need some help",
+ "id": "6de822ab-ceed-4634-8ea8-06c369bbc611",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"I am learning golang, can u prepare a study plan\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "de1705aa-7d2a-49f1-9221-0d1323b02781",
+ "name": "I need some help v1",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"I am learning golang, can u prepare a study plan\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v1"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:49:06 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "189"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \" Sure, I'd be happy to help you prepare a study plan for learning Golang. What kind of timeline are you looking at?\",\n \"chat_id\": \"6bf57d6585cb4a3e85078989bf569051\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "I want to see implementations of concurrency",
+ "id": "1dd78a98-dcee-4f8e-88b5-45c6b8e268c1",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"I want to see implementations of concurrency\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "5fd0e3a0-2611-44a1-a409-67157257a041",
+ "name": "I want to see implementations of concurrency v1",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"I want to see implementations of concurrency\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v1"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:49:21 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "196"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \" Sure, I can help you find implementations of concurrency in Golang. Do you have any specific resources you'd like to use?\",\n \"chat_id\": \"6bf57d6585cb4a3e85078989bf569051\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Give me a breif description of myself v1",
+ "id": "ddb7d1de-a99e-46f4-8253-3bdc3f99c904",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"What i am currently learning? Which programming language am i learning currencly\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "51565ca9-9366-4416-a3f8-3778ebaad393",
+ "name": "Give me a breif description of myself v1",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"What i am currently learning? Which programming language am i learning currencly\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v1",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v1"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Tue, 27 Jun 2023 16:55:35 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "141"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \" It looks like you're learning Golang engineering. Is that correct?\",\n \"chat_id\": \"03c5d673753743c8b38f30da9b58f802\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "PDF Upload",
+ "id": "18ca1eea-e45f-42eb-bdf8-26703283831a",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "PUT",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "file",
+ "type": "file",
+ "src": "go.pdf"
+ },
+ {
+ "key": "",
+ "value": "",
+ "type": "text",
+ "disabled": true
+ }
+ ]
+ },
+ "url": {
+ "raw": "{{u}}/chat/:id/upload/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ ":id",
+ "upload",
+ "v2"
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "{{chat_id}}"
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Specific to pdf",
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "id": "4b286b49-0155-4a47-a0e0-574589d708ed",
+ "exec": [
+ ""
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "id": "e1fa193f-4169-4e03-b29d-e61c6a9c9093",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"which language is described as boring\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "d0ea0a89-0813-4a36-858f-d37c2b7f7447",
+ "name": "Specific to pdf-v2",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"which language is described as boring\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Wed, 28 Jun 2023 11:50:38 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "117"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"The language described as \\\"boring\\\" is Go.\",\n \"chat_id\": \"a455c7bfa34646a5a5baf43516fcdae2\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Ask about PDf",
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "id": "b83cd61a-f1ec-4c14-8b2f-b31e9945cb31",
+ "exec": [
+ "const body = JSON.parse(pm.request.body.raw);",
+ "",
+ "body.message=`",
+ "package main",
+ "import (",
+ "\"fmt\"",
+ "\"time\"",
+ ")",
+ "var counter = 0",
+ "func main() {",
+ "for i := 0; i < 20; i++ {",
+ "go incr()",
+ "}",
+ "time.Sleep(time.Millisecond * 10)",
+ "}",
+ "func incr() {",
+ "counter++",
+ "fmt.Println(counter)",
+ "}",
+ "`",
+ "",
+ "pm.request.body.raw = JSON.stringify(body);"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "id": "35d4abf5-5d08-4385-962b-d5e1b04507e1",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"overwritten in prerequest script\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "d7837243-cf5c-478f-968e-816bc4dc08de",
+ "name": "Generic and related to pdf",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"overwritten in prerequest script\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Wed, 28 Jun 2023 11:51:32 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "255"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"The purpose of the code provided is to demonstrate a simple program in the Go programming language. It is a basic program that prints the message \\\"it's over 9000!\\\" to the console.\",\n \"chat_id\": \"a455c7bfa34646a5a5baf43516fcdae2\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Are u aware of the document",
+ "id": "ebe7867c-b6f6-4744-aac9-ef77116e5d78",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"are u aware of the book-The Little Go Book by Karl Segun\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "response": [
+ {
+ "id": "33a69d64-0c10-46d6-91df-50ffb6c09d5a",
+ "name": "v2",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"sender\": \"user\",\n \"message\": \"are u aware of the book-The Little Go Book by Karl Segun\",\n \"chat_id\":\"{{chat_id}}\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{u}}/chat/v2",
+ "host": [
+ "{{u}}"
+ ],
+ "path": [
+ "chat",
+ "v2"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "date",
+ "value": "Wed, 28 Jun 2023 10:06:06 GMT"
+ },
+ {
+ "key": "server",
+ "value": "uvicorn"
+ },
+ {
+ "key": "content-length",
+ "value": "197"
+ },
+ {
+ "key": "content-type",
+ "value": "application/json"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"sender\": \"bot\",\n \"message\": \"Yes, I am aware of the book \\\"The Little Go Book\\\" by Karl Seguin. It is a beginner's guide to the Go programming language.\",\n \"chat_id\": \"82041296f37b45cf89a4e38bcafb1015\"\n}"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/public/assets/android-chrome-192x192.png b/public/assets/android-chrome-192x192.png
new file mode 100644
index 0000000..3ad8ac4
Binary files /dev/null and b/public/assets/android-chrome-192x192.png differ
diff --git a/public/assets/android-chrome-512x512.png b/public/assets/android-chrome-512x512.png
new file mode 100644
index 0000000..1195fe5
Binary files /dev/null and b/public/assets/android-chrome-512x512.png differ
diff --git a/public/assets/apple-touch-icon.png b/public/assets/apple-touch-icon.png
new file mode 100644
index 0000000..b275886
Binary files /dev/null and b/public/assets/apple-touch-icon.png differ
diff --git a/public/assets/favicon-16x16.png b/public/assets/favicon-16x16.png
new file mode 100644
index 0000000..7f9008e
Binary files /dev/null and b/public/assets/favicon-16x16.png differ
diff --git a/public/assets/favicon-32x32.png b/public/assets/favicon-32x32.png
new file mode 100644
index 0000000..2621f8e
Binary files /dev/null and b/public/assets/favicon-32x32.png differ
diff --git a/public/assets/favicon.ico b/public/assets/favicon.ico
new file mode 100644
index 0000000..970dc81
Binary files /dev/null and b/public/assets/favicon.ico differ
diff --git a/public/assets/robots.txt b/public/assets/robots.txt
new file mode 100755
index 0000000..e9e57dc
--- /dev/null
+++ b/public/assets/robots.txt
@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:
diff --git a/public/assets/site.webmanifest b/public/assets/site.webmanifest
new file mode 100644
index 0000000..7f7f435
--- /dev/null
+++ b/public/assets/site.webmanifest
@@ -0,0 +1,19 @@
+{
+ "name": "AIChats",
+ "short_name": "aichats",
+ "icons": [
+ {
+ "src": "/android-chrome-192x192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "/android-chrome-512x512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ],
+ "theme_color": "#ffffff",
+ "background_color": "#ffffff",
+ "display": "standalone"
+}
diff --git a/src/App.css b/src/App.css
new file mode 100644
index 0000000..b9d355d
--- /dev/null
+++ b/src/App.css
@@ -0,0 +1,42 @@
+#root {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 2rem;
+ text-align: center;
+}
+
+.logo {
+ height: 6em;
+ padding: 1.5em;
+ will-change: filter;
+ transition: filter 300ms;
+}
+.logo:hover {
+ filter: drop-shadow(0 0 2em #646cffaa);
+}
+.logo.react:hover {
+ filter: drop-shadow(0 0 2em #61dafbaa);
+}
+
+@keyframes logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ a:nth-of-type(2) .logo {
+ animation: logo-spin infinite 20s linear;
+ }
+}
+
+.card {
+ padding: 2em;
+}
+
+.read-the-docs {
+ color: #888;
+}
diff --git a/src/App.tsx b/src/App.tsx
new file mode 100644
index 0000000..e23126a
--- /dev/null
+++ b/src/App.tsx
@@ -0,0 +1,15 @@
+import { ChatBoard } from "@modules/ChatBoard";
+
+import { QueryClient, QueryClientProvider } from "react-query";
+
+const queryClient = new QueryClient();
+
+function App() {
+ return (
+
+
+
+ );
+}
+
+export default App;
diff --git a/src/Firebase.ts b/src/Firebase.ts
new file mode 100644
index 0000000..d58c304
--- /dev/null
+++ b/src/Firebase.ts
@@ -0,0 +1,21 @@
+// Import the functions you need from the SDKs you need
+import { initializeApp } from "firebase/app";
+import { getAnalytics } from "firebase/analytics";
+// TODO: Add SDKs for Firebase products that you want to use
+// https://firebase.google.com/docs/web/setup#available-libraries
+
+// Your web app's Firebase configuration
+// For Firebase JS SDK v7.20.0 and later, measurementId is optional
+const firebaseConfig = {
+ apiKey: "AIzaSyCRU-v6F3PhpMq3fQg4jafs7pxOj5gp8H4",
+ authDomain: "aichat-e427b.firebaseapp.com",
+ projectId: "aichat-e427b",
+ storageBucket: "aichat-e427b.appspot.com",
+ messagingSenderId: "438045499105",
+ appId: "1:438045499105:web:814a2045b243bb2824a1a0",
+ measurementId: "G-JZ6NWJ1X9X",
+};
+
+// Initialize Firebase
+const app = initializeApp(firebaseConfig);
+//const analytics = getAnalytics(app);
diff --git a/src/index.css b/src/index.css
new file mode 100644
index 0000000..e51a94f
--- /dev/null
+++ b/src/index.css
@@ -0,0 +1,33 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+
+.custom-gutter-horizontal {
+ width: 0.1rem;
+ --tw-bg-opacity: 1;
+ background-color: rgb(229 231 235 / var(--tw-bg-opacity));
+}
+
+.custom-gutter-horizontal:hover {
+ width: 0.2rem;
+}
+
+.custom-dragger-horizontal {
+ width: 100%;
+}
+
+::-webkit-scrollbar {
+ width: 0.4rem;
+ height: 0.4rem;
+}
+
+::-webkit-scrollbar-track {
+ background-color: white;
+ border-radius: 100vw;
+}
+
+::-webkit-scrollbar-thumb {
+ background-color: #ccc;
+ border-radius: 100vw;
+}
\ No newline at end of file
diff --git a/src/main.tsx b/src/main.tsx
new file mode 100644
index 0000000..02055fd
--- /dev/null
+++ b/src/main.tsx
@@ -0,0 +1,10 @@
+import React from "react";
+import ReactDOM from "react-dom/client";
+import App from "./App";
+import "./index.css";
+
+ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
+
+
+
+);
diff --git a/src/modules/ChatBoard/ChatBoard.tsx b/src/modules/ChatBoard/ChatBoard.tsx
new file mode 100644
index 0000000..2eed4f5
--- /dev/null
+++ b/src/modules/ChatBoard/ChatBoard.tsx
@@ -0,0 +1,11 @@
+import { ChatDisplay } from "./features/ChatDisplay";
+import { SelectBar } from "./features/SelectBar";
+
+export function ChatBoard() {
+ return (
+
+
+
+
+ );
+}
diff --git a/src/modules/ChatBoard/components/ChatForm/ChatForm.tsx b/src/modules/ChatBoard/components/ChatForm/ChatForm.tsx
new file mode 100644
index 0000000..0d774f4
--- /dev/null
+++ b/src/modules/ChatBoard/components/ChatForm/ChatForm.tsx
@@ -0,0 +1,102 @@
+import { useState, useRef } from "react";
+import { PiPaperPlaneRightThin } from "react-icons/pi";
+import { BsPlusCircle } from "react-icons/bs";
+import { BiCloudUpload } from "react-icons/bi";
+import { createChat, getChatById, uploadPdf } from "../../services/api/chat";
+import { useRequestStore } from "@modules/ChatBoard/store/requestStore";
+
+export const ChatForm = () => {
+ const [uploader, setUploader] = useState(false);
+ const [text, setText] = useState("");
+ const [clientId, setClientId] = useState(0);
+ const fileForm = useRef(null);
+ const [selectedFile, setSelectedFile] = useState(null);
+ const reqStore = useRequestStore();
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+ const data = {
+ sender: "user",
+ message: text,
+ chat_id: reqStore.mainchat_id,
+ };
+
+ reqStore.setRequestLoading(true);
+ createChat(data, clientId, "text");
+ setText("");
+ setClientId(clientId + 1);
+ };
+
+ const changeFile = (e: any) => {
+ setSelectedFile(e.target.files[0]);
+ reqStore.setRequestLoading(true);
+ uploadPdf(e.target.files[0], clientId, "file", reqStore.mainchat_id);
+ };
+
+ return (
+
+
changeFile(e)}
+ accept=".pdf"
+ className="hidden"
+ ref={fileForm}
+ />
+ {uploader && (
+
{
+ fileForm.current?.click();
+ setUploader(!uploader);
+ }}
+ className="absolute cursor rounded-md bg-black text-gray-400 flex space-x-3 py-6 px-6 -top-14 left-36 z-30 cursor-pointer"
+ >
+ {" "}
+ Upload pdf
+
+ )}
+
+ {reqStore.requestLoading && (
+
+ processing...
+
+ )}
+
+ search documents and get detailed insights.
+
+
+ );
+};
diff --git a/src/modules/ChatBoard/components/ChatForm/index.ts b/src/modules/ChatBoard/components/ChatForm/index.ts
new file mode 100644
index 0000000..86e91e9
--- /dev/null
+++ b/src/modules/ChatBoard/components/ChatForm/index.ts
@@ -0,0 +1 @@
+export * from "./ChatForm";
diff --git a/src/modules/ChatBoard/components/Display/Display.tsx b/src/modules/ChatBoard/components/Display/Display.tsx
new file mode 100644
index 0000000..4a413a6
--- /dev/null
+++ b/src/modules/ChatBoard/components/Display/Display.tsx
@@ -0,0 +1,141 @@
+import { FaUser } from "react-icons/fa";
+import { BsRobot } from "react-icons/bs";
+import { useRequestStore } from "@modules/ChatBoard/store/requestStore";
+import { useEffect, useState, useRef } from "react";
+import ScrollToBottom from "react-scroll-to-bottom";
+import { useQuery, useQueryClient } from "react-query";
+import { createChat, getChatById } from "@modules/ChatBoard/services/api/chat";
+
+interface IRQ {
+ sender: string;
+ message: string;
+ chat_id: number | null;
+}
+interface IRequest {
+ out: IRQ;
+ in: IRQ;
+ client_id: number;
+ type: string;
+}
+export const Display = () => {
+ const bottomEl = useRef(null);
+ const requestStore = useRequestStore();
+ const [requests, setRequests] = useState([]);
+ const [selectedData, setSelectedData] = useState({});
+ const [chatId, setChatId] = useState(null);
+ const [placeholder, setPlaceholder] = useState("");
+
+ const index = useRef(0);
+ const queryClient = useQueryClient();
+
+ useEffect(() => {
+ if (Object.keys(selectedData).length > 0) {
+ function tick() {
+ setPlaceholder(
+ //@ts-ignore
+ (prev) => prev + selectedData.in.message[index.current]
+ );
+ index.current++;
+ }
+ //@ts-ignore
+ if (index.current < selectedData.in.message.length) {
+ const addChar = setInterval(tick, 500);
+ return () => clearInterval(addChar);
+ }
+ }
+ }, [selectedData, placeholder]);
+
+ //reload problems query
+ // const reloadProblemQuery = () => {
+ // queryClient.invalidateQueries("chats");
+ // };
+
+ // const {} = useQuery(["chats", chatId], () => getChatById(chatId), {
+ // staleTime: 2000,
+ // onSuccess: (data) => {
+ // console.log(data);
+ // },
+ // });
+
+ useEffect(() => {
+ const requestList = requestStore.requests;
+
+ if (requestStore.requests.length > 0) {
+ setRequests(requestList);
+ }
+ }, [requestStore]);
+
+ useEffect(() => {
+ //get last item
+ if (requests.length > 0) {
+ const lastItem = requests[requests.length - 1];
+ const val = new SpeechSynthesisUtterance(`${lastItem.in.message}`);
+ if (lastItem.type.toUpperCase() !== "FILE") {
+ window.speechSynthesis.speak(val);
+ }
+ }
+ }, [requests]);
+
+ useEffect(() => {
+ bottomEl.current?.scrollIntoView({ behavior: "smooth" });
+ window.scrollTo({
+ top: 0,
+ behavior: "smooth",
+ });
+ }, []);
+
+ return (
+
+
+ {requests.length > 0 &&
+ requests.map((req, id) => (
+
+ {/* user */}
+
+
+
+
+
{req.out.message}
+
+ {/* bot */}
+
+
+
+
+
+ {req.in.message}
+
+
+
+ ))}
+ {Object.keys(selectedData).length > 0 && (
+
+ {/* user */}
+
+
+
+
+ {/* @ts-ignore */}
+
{selectedData.out.message}
+
+ {/* bot */}
+
+
+
+
+
+ {placeholder}
+
+
+
+ )}
+
+ {requests.length == 0 && (
+
+
No requests submitted yet
+
+ )}
+
+
+ );
+};
diff --git a/src/modules/ChatBoard/components/Display/index.ts b/src/modules/ChatBoard/components/Display/index.ts
new file mode 100644
index 0000000..699f716
--- /dev/null
+++ b/src/modules/ChatBoard/components/Display/index.ts
@@ -0,0 +1 @@
+export * from "./Display";
diff --git a/src/modules/ChatBoard/features/ChatDisplay/ChatDisplay.tsx b/src/modules/ChatBoard/features/ChatDisplay/ChatDisplay.tsx
new file mode 100644
index 0000000..2d94984
--- /dev/null
+++ b/src/modules/ChatBoard/features/ChatDisplay/ChatDisplay.tsx
@@ -0,0 +1,11 @@
+import { Display } from "@modules/ChatBoard/components/Display";
+import { ChatForm } from "@modules/ChatBoard/components/ChatForm";
+
+export const ChatDisplay = () => {
+ return (
+
+
+
+
+ );
+};
diff --git a/src/modules/ChatBoard/features/ChatDisplay/index.ts b/src/modules/ChatBoard/features/ChatDisplay/index.ts
new file mode 100644
index 0000000..eb0ec18
--- /dev/null
+++ b/src/modules/ChatBoard/features/ChatDisplay/index.ts
@@ -0,0 +1 @@
+export * from "./ChatDisplay";
diff --git a/src/modules/ChatBoard/features/SelectBar/SelectBar.tsx b/src/modules/ChatBoard/features/SelectBar/SelectBar.tsx
new file mode 100644
index 0000000..e433841
--- /dev/null
+++ b/src/modules/ChatBoard/features/SelectBar/SelectBar.tsx
@@ -0,0 +1,55 @@
+import { FcGoogle } from "react-icons/fc";
+import { BiMessageSquareDots } from "react-icons/bi";
+import { useRequestStore } from "@modules/ChatBoard/store/requestStore";
+import { useEffect, useState } from "react";
+
+export const SelectBar = () => {
+ const requestStore = useRequestStore();
+ const [focusedText, setFocusedText] = useState("");
+ useEffect(() => {
+ if (requestStore.requests.length > 0) {
+ setFocusedText(requestStore.requests[0].out.message);
+ console.log(requestStore.requests[0].out.chat_id);
+ }
+ }, [requestStore]);
+ return (
+
+
+ AI Chats
+
+
+ {/* different days list */}
+
+ {/*
Previous 7 days */}
+
+ -
+ {focusedText && }
+
+ {focusedText.substr(0, 30)}{" "}
+ {focusedText.length > 10 ? ". . ." : ""}
+
+
+
+
+
+
+ {/* */}
+ {/* Ikeji chukwunonso */}
+
+
+ );
+};
diff --git a/src/modules/ChatBoard/features/SelectBar/index.ts b/src/modules/ChatBoard/features/SelectBar/index.ts
new file mode 100644
index 0000000..044049e
--- /dev/null
+++ b/src/modules/ChatBoard/features/SelectBar/index.ts
@@ -0,0 +1 @@
+export * from "./SelectBar";
diff --git a/src/modules/ChatBoard/index.ts b/src/modules/ChatBoard/index.ts
new file mode 100644
index 0000000..b58e50f
--- /dev/null
+++ b/src/modules/ChatBoard/index.ts
@@ -0,0 +1 @@
+export * from "./ChatBoard";
diff --git a/src/modules/ChatBoard/services/api/chat/chatApi.ts b/src/modules/ChatBoard/services/api/chat/chatApi.ts
new file mode 100644
index 0000000..3e28db3
--- /dev/null
+++ b/src/modules/ChatBoard/services/api/chat/chatApi.ts
@@ -0,0 +1,112 @@
+import axiosInstance from "@modules/Shared/lib/axiosInstance";
+import { useRequestStore } from "@modules/ChatBoard/store/requestStore";
+import axios from "axios";
+export const createChat = async (
+ data: {
+ sender: string;
+ message: string;
+ chat_id: number | null;
+ },
+ client_id: number,
+ type: string
+) => {
+ try {
+ const res = await axiosInstance({
+ url: "/chat/v2",
+ method: "POST",
+ data: data,
+ });
+ const rData = res.data;
+ useRequestStore.setState({ mainchat_id: rData.chat_id });
+ useRequestStore.setState({
+ requests: [
+ ...useRequestStore.getState().requests,
+ {
+ out: {
+ sender: data.sender,
+ message: data.message,
+ chat_id: rData.chat_id,
+ },
+ in: {
+ sender: rData.sender,
+ message: rData.message,
+ chat_id: rData.chat_id,
+ },
+ client_id: client_id,
+ type,
+ },
+ ],
+ });
+ useRequestStore.setState({ requestLoading: false });
+ return rData;
+ } catch (error) {
+ useRequestStore.setState({ requestLoading: false });
+ return false;
+ }
+};
+export const uploadPdf = async (
+ data: any,
+ client_id: number,
+ type: string,
+ chat_id: number | null
+) => {
+ // console.log(data.name);
+ const formData = new FormData();
+
+ // Update the formData object
+ formData.append("file", data);
+ try {
+ // const res = await axiosInstance({
+ // url: `/chat/${chat_id == null ? 0 : chat_id}/upload`,
+ // method: "POST",
+ // data: data,
+ // });
+ const res = axios.put(
+ `${import.meta.env.VITE_BASE_URL_PROD}/chat/${
+ chat_id
+ }/upload/v2`,
+ formData,
+ {
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ }
+ );
+ const rData = (await res).data;
+ useRequestStore.setState({ mainchat_id: rData.chat_id });
+ useRequestStore.setState({
+ requests: [
+ ...useRequestStore.getState().requests,
+ {
+ out: {
+ sender: "user",
+ message: data.name,
+ chat_id: chat_id,
+ },
+ in: {
+ sender: rData.sender,
+ message: rData.message,
+ chat_id: rData.chat_id,
+ },
+ client_id: client_id,
+ type,
+ },
+ ],
+ });
+ useRequestStore.setState({ requestLoading: false });
+ return rData;
+ } catch (error) {
+ useRequestStore.setState({ requestLoading: false });
+ return false;
+ }
+};
+export const getChatById = async (id: number | null) => {
+ if (id == null) return;
+ const res = await axiosInstance({
+ // url of the api endpoint (can be changed)
+ url: `/chat/${id}`,
+ method: "GET",
+ });
+ // handle success
+ return res;
+};
diff --git a/src/modules/ChatBoard/services/api/chat/index.ts b/src/modules/ChatBoard/services/api/chat/index.ts
new file mode 100644
index 0000000..8264913
--- /dev/null
+++ b/src/modules/ChatBoard/services/api/chat/index.ts
@@ -0,0 +1 @@
+export * from "./chatApi";
diff --git a/src/modules/ChatBoard/store/requestStore.ts b/src/modules/ChatBoard/store/requestStore.ts
new file mode 100644
index 0000000..4ffbb3a
--- /dev/null
+++ b/src/modules/ChatBoard/store/requestStore.ts
@@ -0,0 +1,128 @@
+import { create } from "zustand";
+import { persist } from "zustand/middleware";
+interface IRQ {
+ sender: string;
+ message: string;
+ chat_id: number | null;
+}
+interface IRequest {
+ out: IRQ;
+ in: IRQ;
+ client_id: number;
+ type: string;
+}
+
+interface Request {
+ requests: IRequest[];
+ mainchat_id: number | null;
+ requestLoading: boolean;
+ setRequestLoading: (act: boolean) => void;
+ setRequests: (list: IRequest[]) => void;
+ addRequest: (
+ msg: string,
+ chat_id: number | null,
+ client_id: number,
+ type: string
+ ) => void;
+ updateRequest: (
+ msg: string,
+ chat_id: number,
+ client_id: number,
+ type: string
+ ) => void;
+
+ removeRequests: () => void;
+}
+
+const updateIn = (
+ obj: any,
+ client_id: number,
+ msg: string,
+ chat_id: number
+) => {
+ if (client_id !== obj.client_id) {
+ return obj;
+ } else {
+ obj.in.msg = msg;
+ obj.in.chat_id = chat_id;
+ return obj;
+ }
+};
+const updateOut = (obj: any, client_id: number, chat_id: number) => {
+ if (client_id !== obj.client_id) {
+ return obj;
+ } else {
+ obj.out.chat_id = chat_id;
+ return obj;
+ }
+};
+
+export const useRequestStore = create()(
+ persist(
+ (set) => ({
+ requests: [],
+ mainchat_id: null,
+ type: "",
+ requestLoading: false,
+
+ setRequestLoading(act: boolean) {
+ set(() => ({
+ requestLoading: act,
+ }));
+ },
+ //set requests array
+ setRequests(list: IRequest[]) {
+ set(() => ({
+ requests: list,
+ }));
+ },
+ //add to requests
+ addRequest(msg: string, chat_id, client_id, type) {
+ set((state) => ({
+ requests: [
+ ...state.requests,
+ {
+ out: {
+ sender: "user",
+ message: msg,
+ chat_id: chat_id ? chat_id : null,
+ },
+ in: {
+ sender: "bot",
+ message: "",
+ chat_id: null,
+ },
+ client_id,
+ type,
+ },
+ ],
+ }));
+ },
+
+ //update requests
+ updateRequest(msg: string, chat_id: number, client_id, type) {
+ set((state) => ({
+ requests: state.requests.map((o) => ({
+ ...o,
+ out: updateOut(o, client_id, chat_id),
+ in: updateIn(o, client_id, msg, chat_id),
+ client_id: o.client_id,
+ type,
+ })),
+ }));
+ },
+
+ //delete states
+
+ //clear requests array
+ removeRequests() {
+ set(() => ({
+ requests: [],
+ }));
+ },
+ }),
+ {
+ name: "requestData",
+ }
+ )
+);
diff --git a/src/modules/Shared/lib/axiosInstance.ts b/src/modules/Shared/lib/axiosInstance.ts
new file mode 100644
index 0000000..21a7476
--- /dev/null
+++ b/src/modules/Shared/lib/axiosInstance.ts
@@ -0,0 +1,41 @@
+import axios from "axios";
+const axiosInstance = axios.create({
+ baseURL: import.meta.env.VITE_BASE_URL_PROD,
+ maxRedirects: 2,
+ // headers: {
+ // // Authorization: ``,
+ // "Content-Type": "application/json",
+ // timeout: 1000,
+ // },
+ // .. other options
+});
+
+axiosInstance.interceptors.request.use(
+ (config) => {
+ config.headers["Content-Type"] = "application/json";
+ config.headers["accept"] = "application/json";
+
+ return config;
+ },
+ (error) => {
+ Promise.reject(error);
+ }
+);
+
+axiosInstance.interceptors.response.use(
+ (response) => {
+ return response;
+ },
+ function (error) {
+ // const originalRequest = error.config;
+
+ if (error.response.status === 401) {
+ //session expired, login if wallet address is present
+ // toast.error("Session expired. Authenticating");
+ }
+
+ return Promise.reject(error);
+ }
+);
+
+export default axiosInstance;
diff --git a/src/placeholder.ts b/src/placeholder.ts
new file mode 100644
index 0000000..cb0ff5c
--- /dev/null
+++ b/src/placeholder.ts
@@ -0,0 +1 @@
+export {};
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
new file mode 100644
index 0000000..11f02fe
--- /dev/null
+++ b/src/vite-env.d.ts
@@ -0,0 +1 @@
+///
diff --git a/tailwind.config.js b/tailwind.config.js
new file mode 100644
index 0000000..9d8fc83
--- /dev/null
+++ b/tailwind.config.js
@@ -0,0 +1,8 @@
+/** @type {import('tailwindcss').Config} */
+export default {
+ content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
+ theme: {
+ extend: {},
+ },
+ plugins: [require("@tailwindcss/forms")],
+};
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..cc8b657
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,30 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+ "baseUrl": "./",
+ "paths": {
+ "@modules/*": ["src/modules/*"],
+ "@assets/*": ["public/assets/*"]
+ },
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "react-jsx",
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": false,
+ "noUnusedParameters": false,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src"],
+ "references": [{ "path": "./tsconfig.node.json" }]
+}
diff --git a/tsconfig.node.json b/tsconfig.node.json
new file mode 100644
index 0000000..42872c5
--- /dev/null
+++ b/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "compilerOptions": {
+ "composite": true,
+ "skipLibCheck": true,
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "allowSyntheticDefaultImports": true
+ },
+ "include": ["vite.config.ts"]
+}
diff --git a/vite.config.ts b/vite.config.ts
new file mode 100644
index 0000000..c6c1f4e
--- /dev/null
+++ b/vite.config.ts
@@ -0,0 +1,17 @@
+import { defineConfig } from "vite";
+import react from "@vitejs/plugin-react";
+import path from "path";
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ build: {
+ outDir: "build",
+ },
+ plugins: [react()],
+ resolve: {
+ alias: {
+ "@modules": path.resolve(__dirname, "./src/modules"),
+ "@assets": path.resolve(__dirname, "./public/assets"),
+ },
+ },
+});