Generative AI Document Genie is a Flask application designed to leverage the power of Google's new PaLM 2 generative AI API. This application serves as a powerful tool for interacting with, extracting information from your documents, and now, featuring real-time chat capabilities with Google's cutting-edge Language Learning Models (LLMs). This application is perfect for anyone who needs to quickly find information within their documents or wants to have dynamic and responsive interactions via chat with AI. Whether you're a student researching for a paper, a professional preparing a report, a developer looking to understand a new codebase, or someone who simply wants to explore the potential of conversational AI, this application has something for you.
🌐 Interactive Browser Window Interface:
Experience a seamless and engaging interaction with the AI models right in your browser.
🤖 Integration with PaLM Models for Text Generation:
Harness the power of Google's new PaLM models to generate and interact with text content.
📁 File Loading Functionality to Enhance Content Generation:
Upload documents and enrich your content generation journey.
💾 Easily Save and Clear Your Conversations:
Manage your conversations effectively with the option to save and clear them with ease.
👀 View Models Being Used:
Stay informed with the transparency of knowing which model is being used each time you make a call to the API.
👌 Simple and Intuitive User Interface:
Easy to navigate, our user interface ensures that you focus on generating content and not struggling with complex controls.
- HTML
- CSS (Bootstrap framework)
- JavaScript (jQuery library)
- Python (PaLM models)
- Flask (Python web framework)
Before you get started with Generative AI Document Genie, ensure you have the following:
-
Google Generative PaLM 2 API Key: The Palm 2 API_KEYS at the time of writing still require getting on the waitlist which you can access here.
-
Enable the PaLM API in a new Google Cloud Console project: After obtaining the API key, ensure to enable the PaLM API for your new project. You can learn how to enable APIs in your Google Cloud Console project here.
-
Create a new service account key in JSON format for the project: This is a crucial step for the authentication of your project. You can create and download the JSON key file here.
-
Conda environment (tested using Python 3.10.10): Ensure you have a Conda environment setup and ready to go. If you're new to Conda, you can learn how to get started here.
I've recently updated the embedding functionality in our application from using numpy to ChromaDB. This change has resulted in significant improvements in both query time and response quality. The following are the key benefits of this update:
-
Faster Query Time: ChromaDB is designed for efficient nearest neighbor search, which allows us to find the most relevant passages more quickly compared to the previous numpy-based implementation. This results in a faster and more responsive user experience.
-
Improved Response Quality: ChromaDB's advanced search capabilities enable us to find more relevant passages for the user's query. This leads to higher quality responses generated by the AI model, providing users with more accurate and helpful information.
-
Scalability: ChromaDB is built to handle large-scale datasets, making it an ideal choice for our application as the number of documents and embeddings grows. This ensures that our application can continue to provide fast and accurate results as the dataset expands.
-
I've added a Cosign similarity value for each of the queries generated on the front end at the end of the text.
To get started with the Generative Markdown Genie app, follow these steps:
- Clone the repository:
git clone https://github.com/Nick-Williamz/Palm-DocumentGenie-Webui.git
- Install the Required dependencies:
cd Palm-DocumentGenie-Webui
conda create -n "<name env>" python=3.10.10
pip install -r requirements.txt
$env:GOOGLE_APPLICATION_CREDENTIALS="Path to stored console project json key"
- Start the Flask development server:
python webui_app.py
- Open your web browser and navigate to http://localhost:5000 to access the application.
- Load your documents into the /documents folder. You can delete the example .txt files without issue. (currently only accepting .txt files)
- Once you've loaded the application and navigated to
127.0.0.1:5000
in the browser, you'll see the documents you've added to /documents in the Document View:
- Enter a query into the "Enter a Questions about your Document" field.
- Click the "Submit" button to generate the output based on your query.
- Once output has been generated, if not already created, the conversation.txt is created and the file will contain each of the queries and responses generated.
Note: New queries will be appended to the conversations.txt file UNTIL the document is either manually cleared or the clear button in the browser is pressed.
- To clear conversations.txt file simply tap the clear button in the browser!
To customize the application, you can modify the following sections of the code:
-
Templates and styling: Modify the
index.html
file located in thetemplates
folder to change the layout, design, and styling of the web application. You can also update the CSS styles in thestyles.css
file located in thestatic/css
folder. -
JavaScript: Update the
main.js
file located in thestatic
folder to modify the client-side JavaScript code, such as event handling, form submission, and AJAX requests. -
Flask routes: In the
main_routes.py
file, you can update or add new routes to handle different requests from the client-side. You can also modify the existing route functions to change the behavior of the application. -
Text generation: Modify the
text_generator.py
file to change the text generation process, such as adjusting the temperature, candidate count, or maximum output tokens. -
Document loading: Update the
document_loader.py
file to change the way documents are loaded, such as adding support for different file formats or implementing a different document storage system. -
Embedding generation: In the
embedding_gen.py
file, you can customize the embedding generation process, such as using a different model or modifying the way embeddings are stored and retrieved.
Generative AI for Developers Waitlist: https://developers.generativeai.google/
Generative AI for Developers Palm2 API Documeenation : https://developers.generativeai.google/guide
Contributions to the Generative Markdown Genie app are welcome! If you find any bugs, have feature suggestions, or want to contribute improvements, please follow these steps:
License This project is licensed under the MIT License. See the LICENSE file for more information.