diff --git a/Assets/DocsGPT tee-back.jpeg b/Assets/DocsGPT tee-back.jpeg new file mode 100644 index 000000000..b13fe53d7 Binary files /dev/null and b/Assets/DocsGPT tee-back.jpeg differ diff --git a/Assets/DocsGPT tee-front.jpeg b/Assets/DocsGPT tee-front.jpeg new file mode 100644 index 000000000..8a4b7374c Binary files /dev/null and b/Assets/DocsGPT tee-front.jpeg differ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d864e73f2..c32117a16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,19 +19,31 @@ Thank you for choosing to contribute to DocsGPT! We are all very grateful! - We value contributions in the form of discussions or suggestions. We recommend taking a look at existing issues and our [roadmap](https://github.com/orgs/arc53/projects/2). + - If you're interested in contributing code, here are some important things to know: - We have a frontend built on React (Vite) and a backend in Python. +======= +Before creating issues, please check out how the latest version of our app looks and works by launching it via [Quickstart](https://github.com/arc53/DocsGPT#quickstart) the version on our live demo is slightly modified with login. Your issues should relate to the version that you can launch via [Quickstart](https://github.com/arc53/DocsGPT#quickstart). + +### π¨βπ» If you're interested in contributing code, here are some important things to know: + + +Tech Stack Overview: + +- π Frontend: Built with React (Vite) βοΈ, -### If you are looking to contribute to frontend (βοΈReact, Vite): +- π₯ Backend: Developed in Python π + +### π If you are looking to contribute to frontend (βοΈReact, Vite): - The current frontend is being migrated from [`/application`](https://github.com/arc53/DocsGPT/tree/main/application) to [`/frontend`](https://github.com/arc53/DocsGPT/tree/main/frontend) with a new design, so please contribute to the new one. - Check out this [milestone](https://github.com/arc53/DocsGPT/milestone/1) and its issues. -- The Figma design can be found [here](https://www.figma.com/file/OXLtrl1EAy885to6S69554/DocsGPT?node-id=0%3A1&t=hjWVuxRg9yi5YkJ9-1). +- The updated Figma design can be found [here](https://www.figma.com/file/OXLtrl1EAy885to6S69554/DocsGPT?node-id=0%3A1&t=hjWVuxRg9yi5YkJ9-1). Please try to follow the guidelines. -### If you are looking to contribute to Backend (π Python): +### π₯ If you are looking to contribute to Backend (π Python): - Review our issues and contribute to [`/application`](https://github.com/arc53/DocsGPT/tree/main/application) or [`/scripts`](https://github.com/arc53/DocsGPT/tree/main/scripts) (please disregard old [`ingest_rst.py`](https://github.com/arc53/DocsGPT/blob/main/scripts/old/ingest_rst.py) [`ingest_rst_sphinx.py`](https://github.com/arc53/DocsGPT/blob/main/scripts/old/ingest_rst_sphinx.py) files; they will be deprecated soon). - All new code should be covered with unit tests ([pytest](https://github.com/pytest-dev/pytest)). Please find tests under [`/tests`](https://github.com/arc53/DocsGPT/tree/main/tests) folder. @@ -44,9 +56,62 @@ To run unit tests from the root of the repository, execute: python -m pytest ``` -### Workflow: -Fork the repository, make your changes on your forked version, and then submit those changes as a pull request. +## Workflow π + +Here's a step-by-step guide on how to contribute to DocsGPT: + +1. **Fork the Repository:** + - Click the "Fork" button at the top-right of this repository to create your fork. + +2. **Create and Switch to a New Branch:** + - Create a new branch for your contribution using: + ```shell + git checkout -b your-branch-name + ``` + +3. **Make Changes:** + - Make the required changes in your branch. + +4. **Add Changes to the Staging Area:** + - Add your changes to the staging area using: + ```shell + git add . + ``` + +5. **Commit Your Changes:** + - Commit your changes with a descriptive commit message using: + ```shell + git commit -m "Your descriptive commit message" + ``` + +6. **Push Your Changes to the Remote Repository:** + - Push your branch with changes to your fork on GitHub using: + ```shell + git push origin your-branch-name + ``` + +7. **Submit a Pull Request (PR):** + - Create a Pull Request from your branch to the main repository. Make sure to include a detailed description of your changes and reference any related issues. + +8. **Collaborate:** + - Be responsive to comments and feedback on your PR. + - Make necessary updates as suggested. + - Once your PR is approved, it will be merged into the main repository. + +9. **Testing:** + - Before submitting a Pull Request, ensure your code passes all unit tests. + - To run unit tests from the root of the repository, execute: + ```shell + python -m pytest + ``` + +*Note: You should run the unit test only after making the changes to the backend code.* + +10. **Questions and Collaboration:** + - Feel free to join our Discord. We're very friendly and welcoming to new contributors, so don't hesitate to reach out. + +Thank you for considering contributing to DocsGPT! π ## Questions/collaboration Feel free to join our [Discord](https://discord.gg/n5BX8dh8rU). We're very friendly and welcoming to new contributors, so don't hesitate to reach out. -# Thank you so much for considering contributing to DocsGPT!π +# Thank you so much for considering to contribute DocsGPT!π diff --git a/HACKTOBERFEST.md b/HACKTOBERFEST.md index b16466190..5b693fe94 100644 --- a/HACKTOBERFEST.md +++ b/HACKTOBERFEST.md @@ -32,4 +32,10 @@ Once you have created your PR and our maintainers have merged it, please fill in Feel free to join our Discord server. We're here to help newcomers, so don't hesitate to jump in! [Join us here](https://discord.gg/n5BX8dh8rU). -Thank you very much for considering contributing to DocsGPT during Hacktoberfest! π Your contributions could earn you a stylish new t-shirt as a token of our appreciation. π Join us, and let's code together! π +Thank you very much for considering contributing to DocsGPT during Hacktoberfest! π Your contributions (not just simple typo) could earn you a stylish new t-shirt as a token of our appreciation. π Join us, and let's code together! π + +Here is a preview of the shirts: +
+ + +
diff --git a/README.md b/README.md index 03a3fe830..8105e67e5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@- DocsGPT is a cutting-edge open-source solution that streamlines the process of finding information in project documentation. With its integration of the powerful GPT models, developers can easily ask questions about a project and receive accurate answers. + DocsGPT is a cutting-edge open-source solution that streamlines the process of finding information in the project documentation. With its integration of the powerful GPT models, developers can easily ask questions about a project and receive accurate answers. Say goodbye to time-consuming manual searches, and let DocsGPT help you quickly find the information you need. Try it out and see how it revolutionizes your project documentation experience. Contribute to its development and be a part of the future of AI-powered assistance.
@@ -21,61 +21,56 @@ Say goodbye to time-consuming manual searches, and let - + + ## License + The source code license is [MIT](https://opensource.org/license/mit/), as described in the [LICENSE](LICENSE) file. Built with [π¦οΈπ LangChain](https://github.com/hwchase17/langchain) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 02a0876c3..b80562b20 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -53,6 +53,15 @@ def get_single_conversation(): conversation = conversations_collection.find_one({"_id": ObjectId(conversation_id)}) return jsonify(conversation['queries']) +@user.route("/api/update_conversation_name", methods=["POST"]) +def update_conversation_name(): + # update data for a conversation + data = request.get_json() + id = data["id"] + name = data["name"] + conversations_collection.update_one({"_id": ObjectId(id)},{"$set":{"name":name}}) + return {"status": "ok"} + @user.route("/api/feedback", methods=["POST"]) def api_feedback(): @@ -75,6 +84,19 @@ def api_feedback(): ) return {"status": http.client.responses.get(response.status_code, "ok")} +@user.route("/api/delete_by_ids", methods=["get"]) +def delete_by_ids(): + """Delete by ID. These are the IDs in the vectorstore""" + + ids = request.args.get("path") + if not ids: + return {"status": "error"} + + if settings.VECTOR_STORE == "faiss": + result = vectors_collection.delete_index(ids=ids) + if result: + return {"status": "ok"} + return {"status": "error"} @user.route("/api/delete_old", methods=["get"]) def delete_old(): diff --git a/application/requirements.txt b/application/requirements.txt index b4c712f44..9c60e4219 100644 --- a/application/requirements.txt +++ b/application/requirements.txt @@ -41,7 +41,7 @@ Jinja2==3.1.2 jmespath==1.0.1 joblib==1.2.0 kombu==5.2.4 -langchain==0.0.308 +langchain==0.0.312 loguru==0.6.0 lxml==4.9.2 MarkupSafe==2.1.2 @@ -104,3 +104,4 @@ urllib3==1.26.17 vine==5.0.0 wcwidth==0.2.6 yarl==1.8.2 +sentence-transformers==2.2.2 \ No newline at end of file diff --git a/application/vectorstore/faiss.py b/application/vectorstore/faiss.py index 217b04571..3a0a7b823 100644 --- a/application/vectorstore/faiss.py +++ b/application/vectorstore/faiss.py @@ -1,5 +1,5 @@ -from application.vectorstore.base import BaseVectorStore from langchain.vectorstores import FAISS +from application.vectorstore.base import BaseVectorStore from application.core.settings import settings class FaissStore(BaseVectorStore): @@ -7,20 +7,40 @@ class FaissStore(BaseVectorStore): def __init__(self, path, embeddings_key, docs_init=None): super().__init__() self.path = path + embeddings = self._get_embeddings(settings.EMBEDDINGS_NAME, embeddings_key) if docs_init: self.docsearch = FAISS.from_documents( - docs_init, self._get_embeddings(settings.EMBEDDINGS_NAME, embeddings_key) + docs_init, embeddings ) else: self.docsearch = FAISS.load_local( - self.path, self._get_embeddings(settings.EMBEDDINGS_NAME, settings.EMBEDDINGS_KEY) + self.path, embeddings ) + self.assert_embedding_dimensions(embeddings) def search(self, *args, **kwargs): return self.docsearch.similarity_search(*args, **kwargs) def add_texts(self, *args, **kwargs): return self.docsearch.add_texts(*args, **kwargs) - + def save_local(self, *args, **kwargs): return self.docsearch.save_local(*args, **kwargs) + + def delete_index(self, *args, **kwargs): + return self.docsearch.delete(*args, **kwargs) + + def assert_embedding_dimensions(self, embeddings): + """ + Check that the word embedding dimension of the docsearch index matches + the dimension of the word embeddings used + """ + if settings.EMBEDDINGS_NAME == "huggingface_sentence-transformers/all-mpnet-base-v2": + try: + word_embedding_dimension = embeddings.client[1].word_embedding_dimension + except AttributeError as e: + raise AttributeError("word_embedding_dimension not found in embeddings.client[1]") from e + docsearch_index_dimension = self.docsearch.index.d + if word_embedding_dimension != docsearch_index_dimension: + raise ValueError(f"word_embedding_dimension ({word_embedding_dimension}) " + + f"!= docsearch_index_word_embedding_dimension ({docsearch_index_dimension})") \ No newline at end of file diff --git a/application/worker.py b/application/worker.py index 5c87c7072..71fcd6158 100644 --- a/application/worker.py +++ b/application/worker.py @@ -21,8 +21,7 @@ def metadata_from_filename(title): - store = title.split('/') - store = store[1] + '/' + store[2] + store = '/'.join(title.split('/')[1:3]) return {'title': title, 'store': store} diff --git a/docs/README.md b/docs/README.md index 5b0ef6a47..4e41a0de7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1,53 @@ -# nextra-docsgpt \ No newline at end of file +# nextra-docsgpt + +## Setting Up Docs Folder of DocsGPT Locally + +### 1. Clone the DocsGPT repository: + +``` +git clone https://github.com/arc53/DocsGPT.git + +``` +### 2. Navigate to the docs folder: + +``` +cd DocsGPT/docs + +``` +The docs folder contains the markdown files that make up the documentation. The majority of the files are in the pages directory. Some notable files in this folder include: + +`index.mdx`: The main documentation file. +`_app.js`: This file is used to customize the default Next.js application shell. +`theme.config.jsx`: This file is for configuring the Nextra theme for the documentation. + +### 3. Verify that you have Node.js and npm installed in your system. You can check by running: + +``` +node --version +npm --version + +``` +### 4. If not installed, download Node.js and npm from the respective official websites. + +### 5. Once you have Node.js and npm running, proceed to install yarn - another package manager that helps to manage project dependencies: + +``` +npm install --global yarn + +``` +### 6. Install the project dependencies using yarn: + +``` +yarn install + +``` +### 7. After the successful installation of the project dependencies, start the local server: + +``` +yarn dev + +``` + +- Now, you should be able to view the docs on your local environment by visiting `http://localhost:5000`. You can explore the different markdown files and make changes as you see fit. + +- **Footnotes:** This guide assumes you have Node.js and npm installed. The guide involves running a local server using yarn, and viewing the documentation offline. If you encounter any issues, it may be worth verifying your Node.js and npm installations and whether you have installed yarn correctly. diff --git a/docs/package.json b/docs/package.json index 1585c0a39..c74059739 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,4 +1,10 @@ { +"scripts":{ + "dev": "next dev", + "build": "next build", + "start": "next start" + }, + "license": "MIT", "dependencies": { "@vercel/analytics": "^1.0.2", "docsgpt": "^0.2.4", @@ -8,4 +14,4 @@ "react": "^18.2.0", "react-dom": "^18.2.0" } -} +} \ No newline at end of file diff --git a/docs/pages/Deploying/Hosting-the-app.md b/docs/pages/Deploying/Hosting-the-app.md index 13296b49f..31c3f55a3 100644 --- a/docs/pages/Deploying/Hosting-the-app.md +++ b/docs/pages/Deploying/Hosting-the-app.md @@ -4,39 +4,32 @@ Here's a step-by-step guide on how to setup an Amazon Lightsail instance to host ## Configuring your instance -(If you know how to create a Lightsail instance, you can skip to the recommended configuration part by clicking here). +(If you know how to create a Lightsail instance, you can skip to the recommended configuration part by clicking [here](#connecting-to-your-newly-created-instance)). -### 1. Create an account or login to https://lightsail.aws.amazon.com +### 1. Create an AWS Account: +If you haven't already, create or log in to your AWS account at https://lightsail.aws.amazon.com. -### 2. Click on "Create instance" +### 2. Create an Instance: -### 3. Create your instance +a. Click "Create Instance." -The first step is to select the "Instance location". In most cases, there's no need to switch locations as the default one will work well. +b. Select the "Instance location." In most cases, the default location works fine. -After that, it is time to pick your Instance Image. We recommend using "Linux/Unix" as the image and "Ubuntu 20.04 LTS" as the Operating System. +c. Choose "Linux/Unix" as the image and "Ubuntu 20.04 LTS" as the Operating System. -As for instance plan, it'll vary depending on your unique demands, but a "1 GB, 1vCPU, 40GB SSD and 2TB transfer" setup should cover most scenarios. +d. Configure the instance plan based on your requirements. A "1 GB, 1vCPU, 40GB SSD, and 2TB transfer" setup is recommended for most scenarios. -Lastly, identify your instance by giving it a unique name and then hit "Create instance". +e. Give your instance a unique name and click "Create Instance." -PS: Once you create your instance, it'll likely take a few minutes for the setup to be completed. +PS: It may take a few minutes for the instance setup to complete. -#### The recommended configuration is as follows: +### Connecting to Your newly created Instance -- Ubuntu 20.04 LTS -- 1GB RAM -- 1vCPU -- 40GB SSD Hard Drive -- 2TB transfer +Your instance will be ready a few minutes after creation. To access it, open the instance and click "Connect using SSH." -### Connecting to your newly created instance +#### Clone the DocsGPT Repository -Your instance will be ready for use a few minutes after being created. To access it, just open it up and click on "Connect using SSH". - -#### Clone the repository - -A terminal window will pop up, and the first step will be to clone the DocsGPT git repository: +A terminal window will pop up, and the first step will be to clone the DocsGPT Git repository: `git clone https://github.com/arc53/DocsGPT.git` @@ -56,15 +49,15 @@ And now install docker-compose: `sudo apt install docker-compose` -#### Access the DocsGPT folder +#### Access the DocsGPT Folder -Enter the following command to access the folder in which DocsGPT docker-compose file is present. +Enter the following command to access the folder in which the DocsGPT docker-compose file is present. `cd DocsGPT/` -#### Prepare the environment +#### Prepare the Environment -Inside the DocsGPT folder, create a `.env` file and copy the contents of `.env_sample` into it. +Inside the DocsGPT folder create a `.env` file and copy the contents of `.env_sample` into it. `nano .env` @@ -78,16 +71,16 @@ SELF_HOSTED_MODEL=false To save the file, press CTRL+X, then Y, and then ENTER. -Next, we need to set a correct IP for our Backend. To do so, open the docker-compose.yml file: +Next, set the correct IP for the Backend by opening the docker-compose.yml file: `nano docker-compose.yml` -And change this line 7 `VITE_API_HOST=http://localhost:7091` +And Change line 7 to: `VITE_API_HOST=http://localhost:7091` to this `VITE_API_HOST=http://