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](https://github.com/aichats/aichats/assets/24226219/6dc98a69-03bd-461f-ae88-39a61fac59d5) + +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 +
+ )} +
+
+ +