Giter Site home page Giter Site logo

bibek12345 / chatpdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akshata29/entaoai

0.0 0.0 0.0 11.84 MB

Chat and Ask on your own data. Accelerator to quickly upload your own enterprise data and use OpenAI services to chat to that uploaded data and ask questions

Python 40.55% TypeScript 47.81% CSS 6.75% HTML 0.08% Bicep 4.81%

chatpdf's Introduction

ChatGPT + Enterprise data with Azure OpenAI

This sample demonstrates a few approaches for creating ChatGPT-like experiences over your own data. It uses Azure OpenAI Service to access the ChatGPT model (gpt-35-turbo and gpt3), and vector store (Pinecone, Redis and others) or Azure cognitive search for data indexing and retrieval.

The repo provides a way to upload your own data so it's ready to try end to end.

Updates

  • 3/16/2023 - Initial Release, Ask your Data and Chat with your Data
  • 3/17/2023
    • Support uploading Multiple documents
    • Bug fix - Redis Vectorstore Implementation
  • 3/18/2023 - API to generate summary on documents & Sample QA
  • 3/19/2023 - Add GPT3 Chat Implementation
  • 3/23/2023 - Add Cognitive Search as option to store documents
  • 3/29/2023 - Automated Deployment script
  • 4/8/2023 - Ask your SQL - Using SQL Database Agent or Using SQL Database Chain
  • 4/13/2023 - Add new feature to support asking questions on multiple document using Vector QA Agent

Test Website

Chat and Ask over your data

Features

  • Upload (PDF/Text Documents as well as Webpages). New - Connectors support. Connect to your data directly from the Azure Container or a specific file. You can also connect to AWS S3 Bucket & key. Upload
  • Chat - Chat to your document (GPT3 or ChatGpt) Chat
  • Q&A interfaces Ask
  • SQL Agent - Talk to your databases using Natural language. This use-case showcases how using the prompt engineering approach from Chain of Thought modelling we can make it scalable and further use LLM capability of generating SQL Code from Natural Language by providing the context without the need to know the DB schema before hand. SqlAgent
  • Edgar Analysis Coming Soon - Talk to & Search all SEC documents Edgar
  • Developer Settings - Developer configurations and settings that can be configured for your dataset Developer
  • Explores various options to help users evaluate the trustworthiness of responses with citations, tracking of source content, etc. Thoughts
  • Shows possible approaches for data preparation, prompt construction, and orchestration of interaction between model (ChatGPT) and retriever
  • Integration with Cognitive Search and Vector stores (Redis, Pinecone)

Architecture

Architecture

Getting Started

NOTE In order to deploy and run this example, you'll need an Azure subscription with access enabled for the Azure OpenAI service. You can request access here.

Prerequisites

To Run Locally

Installation

  1. Deploy the required Azure Services - Using scripts and steps below:

    1. Git clone the repo
    2. Download the pre-requisites above
    3. Run azd login to login to Azure using your credentials
    4. Run azd init to initialize the environment name, subscription & location
      1. enter environment name, select subscription & location
    5. Run azd env set AZURE_PREFIX <PrefixName> - Replace prefix name that will be used during deployment
    6. Run azd up to deploy the infrastructure code (azure services) and deploy the Azure functions as well as Backend app

    Note Ensure that the location you select is the location where OpenAI service is available to deploy (https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability)

    1. Above command will deploy following services
      1. Azure App Service Plan (Linux - B1 Tier)
      2. Cognitive Search Service (Standard Tier)
      3. Azure App Service (To Deploy backend service)
      4. Azure Function app (For all Python API)
      5. Storage Account (to store all your files) & Function storage account
      6. Azure Open AI Service
      7. Azure Application Insight

    Note External vector store are not deployed and you will need to manually deploy them (Pinecone or Redis)

  2. Alternatively deploy the following services manually

    1. OpenAI service. Please be aware of the model & region availability documented [here] (https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability)
    2. Storage Account and a container
    3. One of the Document Store
      1. Pinecone Starter. Note Make sure you create the index in Pincone with dimensions as 1536 and metric as cosine
      2. Cognitive Search
      3. Redis
    4. Create Function App (https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-function-app-portal)
    5. Create Azure Web App
    6. Git clone the repo
    7. Open the cloned repo folder in VSCode
    8. Open new terminal and go to /app/frontend directory
    9. Run npm install to install all the packages
    10. Go to /api/Python directory
    11. Run pip install -r requirements.txt to install all required python packages
    12. Copy sample.settings.json to local.settings.json
    13. Update the configuration (Minimally you need OpenAi, one of the document store, storage account)
    14. Deploy the Azure Python API to Function app
    15. Open new terminal and go to /app/frontend directory
    16. Run npm run build for production build and copying static files to app/backend/static directory
    17. Open new terminal and go to /app/backend directory
    18. Copy env.example to .env file and edit the file to enter the Python localhost API and the storage configuration
    19. Deploy the app/backend Azure web app.

Run Locally

  1. Git clone the repo
  2. Open the cloned repo folder in VSCode
  3. Open new terminal and go to /app/frontend directory
  4. Run npm install to install all the packages
  5. Go to /api/Python directory
  6. Run pip install -r requirements.txt to install all required python packages
  7. Copy sample.settings.json to local.settings.json
  8. Update the configuration (Minimally you need OpenAi, one of the document store, storage account)
  9. Start the Python API by running func host start
  10. Open new terminal and go to /app/backend directory
  11. Copy env.example to .env file and edit the file to enter the Python localhost API and the storage configuration
  12. Run py app.py to start the backend locally (on port 5000)
  13. Open new terminal and go to /app/frontend directory
  14. Run npm run dev to start the local server (on port 5173)
  15. Browse the localhost:5173 to open the web app.

Once in the web app:

  • Try different topics in chat or Q&A context. For chat, try follow up questions, clarifications, ask to simplify or elaborate on answer, etc.
  • Explore citations and sources
  • Click on "settings" to try different options, tweak prompts, etc.

Resources

Note

Adapted from the Azure OpenAI Search repo at OpenAI-CogSearch

chatpdf's People

Contributors

akshata29 avatar vishnu6266 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.