From 267cfb621efe031636824fae83bdd82d3284e5f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:25:02 +0000 Subject: [PATCH 1/7] Bump express from 4.18.2 to 4.19.2 in /mock-backend Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2. - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/master/History.md) - [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2) --- updated-dependencies: - dependency-name: express dependency-type: indirect ... Signed-off-by: dependabot[bot] --- mock-backend/package-lock.json | 53 +++++----------------------------- 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/mock-backend/package-lock.json b/mock-backend/package-lock.json index 2d070b79..24073421 100644 --- a/mock-backend/package-lock.json +++ b/mock-backend/package-lock.json @@ -357,9 +357,9 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -458,16 +458,16 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -515,43 +515,6 @@ "isarray": "0.0.1" } }, - "node_modules/express/node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/express/node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/express/node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", From b673aaf9f0ac72120bd98ef1f9169c67d9e0a051 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:53:09 +0000 Subject: [PATCH 2/7] Bump vite from 5.0.12 to 5.0.13 in /frontend Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.12 to 5.0.13. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v5.0.13/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.0.13/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- frontend/package-lock.json | 8 ++++---- frontend/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 8b8f0238..98aedce0 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -44,7 +44,7 @@ "prettier-plugin-tailwindcss": "^0.2.2", "tailwindcss": "^3.2.4", "typescript": "^4.9.5", - "vite": "^5.0.12", + "vite": "^5.0.13", "vite-plugin-svgr": "^4.2.0" } }, @@ -7855,9 +7855,9 @@ } }, "node_modules/vite": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz", - "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.13.tgz", + "integrity": "sha512-/9ovhv2M2dGTuA+dY93B9trfyWMDRQw2jdVBhHNP6wr0oF34wG2i/N55801iZIpgUpnHDm4F/FabGQLyc+eOgg==", "dev": true, "dependencies": { "esbuild": "^0.19.3", diff --git a/frontend/package.json b/frontend/package.json index 0c7dead4..6e8d8e60 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -55,7 +55,7 @@ "prettier-plugin-tailwindcss": "^0.2.2", "tailwindcss": "^3.2.4", "typescript": "^4.9.5", - "vite": "^5.0.12", + "vite": "^5.0.13", "vite-plugin-svgr": "^4.2.0" } } From 6e147b3ed27d8b39d3b0da12f70e74429a7378bf Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 5 Apr 2024 14:49:32 +0100 Subject: [PATCH 3/7] Update api key to new data --- docs/pages/_app.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/_app.mdx b/docs/pages/_app.mdx index 992283cc..39c01574 100644 --- a/docs/pages/_app.mdx +++ b/docs/pages/_app.mdx @@ -4,7 +4,7 @@ export default function MyApp({ Component, pageProps }) { return ( <> - + ) } \ No newline at end of file From 79ce8d65635231a544df626ad50ef51a53bca3bc Mon Sep 17 00:00:00 2001 From: Pavel Date: Sun, 7 Apr 2024 20:14:16 +0400 Subject: [PATCH 4/7] guide --- docs/pages/Extensions/_meta.json | 10 ++++++--- docs/pages/Extensions/api-key-guide.md | 30 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 docs/pages/Extensions/api-key-guide.md diff --git a/docs/pages/Extensions/_meta.json b/docs/pages/Extensions/_meta.json index 05a49916..8ce9b786 100644 --- a/docs/pages/Extensions/_meta.json +++ b/docs/pages/Extensions/_meta.json @@ -4,7 +4,11 @@ "href": "/Extensions/Chatwoot-extension" }, "react-widget": { - "title": "🏗️ Widget setup", - "href": "/Extensions/react-widget" - } + "title": "🏗️ Widget setup", + "href": "/Extensions/react-widget" + }, + "api-key-guide": { + "title": "🔐 API Keys guide", + "href": "/Extensions/api-key-guide" + } } \ No newline at end of file diff --git a/docs/pages/Extensions/api-key-guide.md b/docs/pages/Extensions/api-key-guide.md new file mode 100644 index 00000000..6ba30a0b --- /dev/null +++ b/docs/pages/Extensions/api-key-guide.md @@ -0,0 +1,30 @@ +## Guide to DocsGPT API Keys + +DocsGPT API keys are essential for developers and users who wish to integrate the DocsGPT models into external applications, such as the our widget. This guide will walk you through the steps of obtaining an API key, starting from uploading your document to understanding the key variables associated with API keys. + +### Uploading Your Document + +Before creating your first API key, you must upload the document that will be linked to this key. You can upload your document through two methods: + +- **GUI Web App Upload:** A user-friendly graphical interface that allows for easy upload and management of documents. +- **Using `/api/upload` Method:** For users comfortable with API calls, this method provides a direct way to upload documents. + +### Obtaining Your API Key + +After uploading your document, you can obtain an API key either through the graphical user interface or via an API call: + +- **Graphical User Interface:** Navigate to the Settings section of the DocsGPT web app, find the API Keys option, and press 'Create New' to generate your key. +- **API Call:** Alternatively, you can use the `/api/create_api_key` endpoint to create a new API key. For detailed instructions, visit [DocsGPT API Documentation](https://docs.docsgpt.co.uk/Developing/API-docs#8-apicreate_api_key). + +### Understanding Key Variables + +Upon creating your API key, you will encounter several key variables. Each serves a specific purpose: + +- **Name:** Assign a name to your API key for easy identification. +- **Source:** Indicates the source document(s) linked to your API key, which DocsGPT will use to generate responses. +- **ID:** A unique identifier for your API key. You can view this by making a call to `/api/get_api_keys`. +- **Key:** The API key itself, which will be used in your application to authenticate API requests. + +With your API key ready, you can now integrate DocsGPT into your application, such as the DocsGPT Widget or any other software, via `/api/answer` or `/stream` endpoints. The source document is preset with the API key, allowing you to bypass fields like `selectDocs` and `active_docs` during implementation. + +Congratulations on taking the first step towards enhancing your applications with DocsGPT! With this guide, you're now equipped to navigate the process of obtaining and understanding DocsGPT API keys. \ No newline at end of file From db8db9fae964ce9e8977c39c0d4fe161775de3e5 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Apr 2024 10:35:15 +0100 Subject: [PATCH 5/7] Add prompt_id and chunks fields in create_api_key function --- docs/pages/Developing/API-docs.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/pages/Developing/API-docs.md b/docs/pages/Developing/API-docs.md index c5bd8970..a85ed6f8 100644 --- a/docs/pages/Developing/API-docs.md +++ b/docs/pages/Developing/API-docs.md @@ -281,6 +281,8 @@ Create a new API key for the user. **Request Body**: JSON object with the following fields: * `name` — A name for the API key. * `source` — The source documents that will be used. +* `prompt_id` — The prompt ID. +* `chunks` — The number of chunks used to process an answer. Here is a JavaScript Fetch Request example: ```js @@ -290,7 +292,10 @@ fetch("http://127.0.0.1:5000/api/create_api_key", { "headers": { "Content-Type": "application/json; charset=utf-8" }, - "body": JSON.stringify({"name":"Example Key Name","source":"Example Source"}) + "body": JSON.stringify({"name":"Example Key Name", + "source":"Example Source", + "prompt_id":"creative", + "chunks":"2"}) }) .then((res) => res.json()) .then(console.log.bind(console)) From d36f58230a326ecacb9c32a4ae8eac65666044f2 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Apr 2024 12:56:27 +0100 Subject: [PATCH 6/7] advisory-fix --- application/api/user/routes.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index b1ec69e4..ec75554e 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -1,6 +1,7 @@ import os import uuid from flask import Blueprint, request, jsonify +from urllib.parse import urlparse import requests from pymongo import MongoClient from bson.objectid import ObjectId @@ -252,20 +253,26 @@ def check_docs(): if os.path.exists(vectorstore) or data["docs"] == "default": return {"status": "exists"} else: - r = requests.get(base_path + vectorstore + "index.faiss") + file_url = urlparse(base_path + vectorstore + "index.faiss") + + if file_url.scheme in ['https'] and file_url.netloc == 'raw.githubusercontent.com' and file_url.path.startswith('/arc53/DocsHUB/main/'): + + r = requests.get(file_url.geturl()) - if r.status_code != 200: - return {"status": "null"} + if r.status_code != 200: + return {"status": "null"} + else: + if not os.path.exists(vectorstore): + os.makedirs(vectorstore) + with open(vectorstore + "index.faiss", "wb") as f: + f.write(r.content) + + # download the store + r = requests.get(base_path + vectorstore + "index.pkl") + with open(vectorstore + "index.pkl", "wb") as f: + f.write(r.content) else: - if not os.path.exists(vectorstore): - os.makedirs(vectorstore) - with open(vectorstore + "index.faiss", "wb") as f: - f.write(r.content) - - # download the store - r = requests.get(base_path + vectorstore + "index.pkl") - with open(vectorstore + "index.pkl", "wb") as f: - f.write(r.content) + return {"status": "null"} return {"status": "loaded"} From 6911f8652a4b4c79f3aa2cd38d71ec337dcdf534 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Apr 2024 13:06:05 +0100 Subject: [PATCH 7/7] Fix vectorstore path in check_docs function --- application/api/user/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index ec75554e..e80ec52b 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -248,7 +248,7 @@ def check_docs(): # split docs on / and take first part if data["docs"].split("/")[0] == "local": return {"status": "exists"} - vectorstore = "vectors/" + data["docs"] + vectorstore = "vectors/" + secure_filename(data["docs"]) base_path = "https://raw.githubusercontent.com/arc53/DocsHUB/main/" if os.path.exists(vectorstore) or data["docs"] == "default": return {"status": "exists"}