PaLM 2 Generative Text Genie 🧞

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.

⚠️ Note: Running this application requires access to a Google Generative PaLM 2 API Key, which currently has a waiting list.

Image showing working application running in browser

Features

🌐 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.

Technologies Used

  • HTML
  • CSS (Bootstrap framework)
  • JavaScript (jQuery library)
  • Python (PaLM models)
  • Flask (Python web framework)

🔑 Prerequisites

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.

🆕 Update (5/21/23) Improved Document Search and Output via ChromaDB

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:

  1. 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.

  2. 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.

  3. 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.

  4. I've added a Cosign similarity value for each of the queries generated on the front end at the end of the text.

Image showign new feature added to chat window

Getting Started

To get started with the Generative Markdown Genie app, follow these steps:

  1. Clone the repository:
   git clone https://github.com/Nick-Williamz/Palm-DocumentGenie-Webui.git
  1. 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"
  1. Start the Flask development server:
python webui_app.py
  1. Open your web browser and navigate to http://localhost:5000 to access the application.

Usage

  1. Load your documents into the /documents folder. You can delete the example .txt files without issue. (currently only accepting .txt files)
  2. 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:

Image showing document view during runtime

  1. Enter a query into the "Enter a Questions about your Document" field.
  2. Click the "Submit" button to generate the output based on your query.
  3. 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.

  1. To clear conversations.txt file simply tap the clear button in the browser!

Customization

To customize the application, you can modify the following sections of the code:

  1. Templates and styling: Modify the index.html file located in the templates folder to change the layout, design, and styling of the web application. You can also update the CSS styles in the styles.css file located in the static/css folder.

  2. JavaScript: Update the main.js file located in the static folder to modify the client-side JavaScript code, such as event handling, form submission, and AJAX requests.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Useful Links 🔗

Generative AI for Developers Waitlist: https://developers.generativeai.google/
Generative AI for Developers Palm2 API Documeenation : https://developers.generativeai.google/guide

Contributing

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.