Git Product home page Git Product logo

flaskgpt's Introduction

FlaskGPT

FlaskGPT is a minimal ChatGPT clone that leverages the langchain library to provide an interactive graphical user interface (GUI) for querying a JSON file, specifically the resume.json file from the resume.json project. This project is indebted to Thomas Davis for the use of his resume.json file.

The main objective of FlaskGPT is to enable users to ask questions interactively using a Large Language Model (LLM) in combination with the resume.json file, which has been converted into a vector database. The project is implemented using Flask and is designed to work with an OpenAI model or a Llama2-based LLM model (gguf file format).

Credits

FlaskGPT is inspired by the work of Himanshu Sekhar Das on InfoGPT, a similar project built using Streamlit. While InfoGPT offers a more extensive feature set and supports a wider range of file formats, FlaskGPT aims to provide a minimalistic and Flask-based alternative.

Features

  • Interactive GUI for querying the resume.json file.
  • Utilizes a Large Language Model (LLM) to generate responses.
  • Supports the OpenAI API and the Llama2-based LLM model (gguf files only).
  • Real-time token output using Server-Sent Events (SSE).

Screenshot

FlaskGPT

Getting Started

  1. Clone the repository:

    git clone https://github.com/benbaker76/FlaskGPT.git
    cd FlaskGPT
  2. I recommend using a virtual environment:

    python -m venv .venv
    source .venv/bin/activate
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Set up your OpenAI API credentials by following the instructions in the OpenAI documentation. Make sure your OPENAI_API_KEY environment variable is set.

    export OPENAI_API_KEY=<your secret key>
  5. Start the Flask server:

    python3 FlaskGPT.py
  6. Access the FlaskGPT GUI by opening a web browser and navigating to http://localhost:5000.

Usage

  1. Launch the FlaskGPT GUI as described in the "Getting Started" section.
  2. Use the interface to ask questions based on the resume.json file.
  3. Enjoy real-time token output and responses from the Large Language Model.

How Does it Work?

This work is based on the principle of Retrieval Augmentation Generation (RAG) which is an approach in the field of Natural Language Processing (NLP) that combines three key components: retrieval, augmentation, and generation. This approach is designed to improve the performance and capabilities of language models.

RAG Diagram

Token Limits: Vector databases play a crucial role in enabling large language models (LLMs) to manage extensive data within token constraints. These databases store and index vector representations of text, allowing LLMs to retrieve relevant segments efficiently. For instance, in this demo, the default OpenAI model, gpt-3.5-turbo, has a maximum context length of 4097 tokens. Vector databases facilitate optimal data utilization by helping LLMs produce coherent responses while working within these limitations.

Text Splitting and Embedding: In this process, we break down the document's content into smaller units that encapsulate document metadata. After dividing the document into these smaller chunks, we employ a vector embedding model to convert them into representations stored in the vector database.

Retrieval: Retrieval refers to the process of accessing and obtaining specific information or data from a database. It involves searching for and returning relevant items or documents based on user queries or criteria.

Output Generation: Output Generation occurs after obtaining relevant context from the retriever component. This context is then used as input for the Language Model (LLM), which generates an appropriate response or answer based on the user's query. This step is crucial in providing accurate and contextually relevant responses to user queries. Langchain plays a role in chaining the llm, retriever and prompts to give the final answer which we stream through Flask ui.

Contributing

Contributions to FlaskGPT are welcome! If you'd like to contribute, please fork the repository and create a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links

flaskgpt's People

Contributors

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