Skip to content

Commit

Permalink
Merge pull request #36 from Daethyra/3.0.0-mpa
Browse files Browse the repository at this point in the history
Multi-Page Application
  • Loading branch information
Daethyra authored Feb 26, 2024
2 parents 9991626 + aacedcf commit c429e2f
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 48 deletions.
88 changes: 66 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
Providing AI solutions for everyday people

***TLDR***:
- A general purpose chatbot assistant
- Free access to generative AI models
- Unlimited file uploads (per user-session; deletes data on exiting the web page)
- Leverage state of the art RAG techniques for accurate, helpful text generation without managing the underlying prompt-engineering
- No AI model training on your data
- No sign-up or login required
- Offers AI tooling like a general-purpose chatbot assistant
- Provides free access to generative AI models
- Accepts unlimited file uploads (per user session; deletes data upon exit)
- Leverages state-of-the-art RAG techniques for accurate, helpful responses without requiring complex prompt engineering
- Protects privacy – no AI model training on your data, no sign-up needed

## Table of Contents

Expand All @@ -17,11 +16,15 @@ Providing AI solutions for everyday people
- [Description](#description)
- [Vocabulary](#critical-vocabulary)
- [Current Functionality](#what-can-freestream-do-for-me-currently)
- [Future Functionality Plans](#future-functionality-plans)
- [Functional Requirements](#functional-requirements)
- [Non-Functional Requirements](#non-functional-requirements)
- [Roadmap](#roadmap)
- [Thinking Out Loud](#thinking-out-loud)
- [Future Functionality Plans](#future-functionality-plans)

## Quickstart

As of version 1.0.1, a test version is hosted via Streamlit Community Cloud, [here](https://freestream.streamlit.app/ "Version 2.0.0")
As of version 1.0.1, a test version is hosted via Streamlit Community Cloud, [here](https://freestream.streamlit.app/ "Current Version: 3.0.0")

### Installation

Expand All @@ -42,7 +45,7 @@ poetry run streamlit run ./freestream/main.py
---

## Description
The original inspiration for this project was to create a chatbot for friends in law and medicine, but I quickly realized the system should be flexible enough to serve in any domain.
I originally created this project as a chatbot for law and medical professionals, but I quickly realized a more flexible system would benefit everyone.

#### -- **Critical Vocabulary** --

Expand All @@ -54,26 +57,67 @@ The original inspiration for this project was to create a chatbot for friends in

### What can FreeStream do for me, currently?

Right now, FreeStream is basically a chatbot powered by GPT-3.5-Turbo that requires that you upload a file(s) before you interact with it. You'll take advantage of state of the art prompt-engineering logical flow that helps ensure the best results are retrieved from your uploaded files.
FreeStream functions as a chatbot powered by GPT-3.5-Turbo. Upload a file (or files) and take advantage of advanced prompt engineering for the most helpful results based on your uploaded content.

#### Things worth noting:
- Currently only supports the GPT-3.5-Turbo model
- The implemented RAG chain forces answers to be based on the context, and the context only. This makes it difficult to interact with the chat history in a nuanced, meaningful way.
**Note**:
* Only supports the GPT-3.5-Turbo model
- The implemented RAG logic strictly adheres to the uploaded context. This limits meaningful interaction with the chat history.

## Roadmapping Out Loud
The current focus is to overhaul the retrieval prompting by removing `ConversationalRetrievalChain`, as it hard codes the logical flow of prompting, retrieving, prompting, and responding to the user, and it also makes it difficult to get nuanced answers. The fix for this is to implement LangGraph so that I have control over "nodes" and "edges", which basically means I'll have absolute control over how the AI makes its decisions, drastically enhancing the generated responses' helpfulness and pertinence to the query.
## Functional Requirements

The application **MUST**...
1. Provide a user interface for chatbot interactions and optional file uploads.
2. Allow users to upscale images (PDF, JPEG, PNG, BMP, SVG) without limits.
3. Enable users to remove objects from uploaded images. This requires:
* Object detection
* Object removal
* Inpainting
* [HuggingFace Resource](https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint)
* [HF Mask Maker (Space)](https://huggingface.co/spaces/daethyra/inpaint-mask-maker)
4. Let users generate tasks based on their speech
5. Include a privacy policy that clearly outlines data usage when interacting with GPT-3.5 or Gemini-Pro
6. Provide a "Submit Report/Request" form

## "Non-Functional Requirements

The application **SHOULD**...
1. Aim for 24/7 availability.
2. Use a multi-page Streamlit application structure.
3. Prioritize ease of navigation
4. Feature a visually appealing design.
5. Position itself as a toolbox for niche professional workflows.
6. Offer multiple chat models

# Roadmap

## Thinking Out Loud
I'm focusing on overhauling the retrieval prompting logic. I'll remove `ConversationalRetrievalChain` because it restricts flexibility and nuanced answers. I'll either adopt `AgentExecutor` or implement LangGraph for greater control over AI decision-making, hopefully improving response quality.

## Future Functionality Plans

- [x] Create an RAG chatbot
- [ ] Add Gemini-Pro to the model list
- [x] Add Gemini-Pro to the model list
- [ ] Integrate [`StreamlitCallbackHandler`](https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.streamlit.streamlit_callback_handler.StreamlitCallbackHandler.html "Python API Documentation")
- [ ] Add AI decision making
- [ ] Implement Corrective-RAG
- [ ] Turn into a Multi-Page Application (MPA)
- [ ] (Homepage) Add a welcome screen with a description and table of contents
- [ ] (Page) Migrate RAG SPA code
- [ ] (Page) Add habit tracking spreadsheet template with visualization feature
- [ ] (Page) Add a "Task Transcriber" page that transcribes the user's speech into a task outlined with details and requirements, along with action steps to enact the plan
- [ ] Implement Corrective-RAG OR Reflective-RAG
- [x] Turn into a Multi-Page Application (MPA)
- [x] (Homepage) Add a welcome screen with...
- [x] a description of the project
- [ ] ~~table of contents~~
- [ ] privacy policy
- [ ] "Report/Request" form
- [x] (Page) Migrate RAG SPA code
- [ ] Add "Temperature" slider
- [ ] (Page) Add a "Task Transcriber"
- [ ] Microphone input (Record in browser)
- [ ] Transcribes audio to text
- [ ] Use LLM to identify each and every task while grouping some to avoid redundance
- [ ] Generates text within a predefined task template, for each task identified
- [ ] (Page) Add "Image Upscaler"
- [ ] Multi-file upload
- [ ] File type detection
- [ ] (Page) Add "Object Removal" from images
- [ ] Review HuggingFace Spaces's as a potential solution

---

Expand Down
22 changes: 13 additions & 9 deletions freestream/main.py → freestream/pages/1_🤖_RAGbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from langchain.memory import ConversationBufferMemory
from langchain_community.chat_message_histories import StreamlitChatMessageHistory
from langchain.chains import ConversationalRetrievalChain
from utility_funcs import (
from pages.utils.utility_funcs import (
configure_retriever,
StreamHandler,
PrintRetrievalHandler,
Expand All @@ -14,15 +14,15 @@

# Initialize LangSmith tracing
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_PROJECT"] = "FreeStream-v2.0.2"
os.environ["LANGCHAIN_PROJECT"] = "FreeStream-v3.0.0"
os.environ["LANGCHAIN_ENDPOINT"] = st.secrets.LANGCHAIN.LANGCHAIN_ENDPOINT
os.environ["LANGCHAIN_API_KEY"] = st.secrets.LANGCHAIN.LANGCHAIN_API_KEY

# Set up page config
st.set_page_config(page_title="FreeStream: Free AI Tooling", page_icon="🗣️📄")
st.title("FreeStream")
st.header(":green[_Welcome_]", divider="red")
st.caption(":violet[_General purpose chatbot assistant_]")
st.set_page_config(page_title="FreeStream: RAGbot", page_icon="🤖")
st.title("🤖:rainbow[RAGbot]")
st.header(":green[_Retrieval Augmented Generation Chatbot_]", divider="red")
st.caption(":violet[_Ask Your Documents Questions_]")
st.sidebar.subheader("__User Panel__")

# Add a way to upload files
Expand Down Expand Up @@ -56,10 +56,12 @@
"Gemini-Pro": ChatGoogleGenerativeAI(
model="gemini-pro",
google_api_key=st.secrets.GOOGLE.google_api_key,
temperature=0.5,
top_k=40,
top_p=0.65,
temperature=0,
top_k=50,
top_p=1,
convert_system_message_to_human=True,
max_output_tokens=512,
max_retries=1,
)
}

Expand Down Expand Up @@ -109,6 +111,8 @@
response = qa_chain.run(
user_query, callbacks=[retrieval_handler, stream_handler]
)
# Force Gemini's message to display
# I'm unsure why it doesn't work like GPT-3.5
if selected_model == "Gemini-Pro":
st.write(response)
st.toast("Success!", icon="✅")
Empty file.
File renamed without changes.
31 changes: 31 additions & 0 deletions freestream/🏡_Home.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import streamlit as st

st.set_page_config(
page_title="FreeStream: Unlimited Access to AI Tools",
page_icon="🏡"
)

st.title(":rainbow[FreeStream]")
st.header(":green[_Unlimited Access to AI Tools_]", divider="red")
# Project Overview
st.subheader("What is FreeStream?")
st.write(
"""
FreeStream is a project I'm working on to make AI tools more accessible. It's not just about having a chatbot; it's about exploring how AI can help us in our daily lives, today and in the future. Here's what you can do with FreeStream:
* **Explore AI Tools:** Dive into a wide range of AI tools, from chatbots to document analysis, to discover what's possible.
* **Educate Yourself:** Engage in interactive experiences designed to deepen your understanding of AI and its capabilities.
* **Solve Real-World Problems:** Utilize AI tools to simplify and enhance your daily tasks, showcasing the power of AI in action.
"""
)

st.divider()
st.subheader("What tools are currently available?")
st.write(
"""
Currently, FreeStream offers a range of AI tools, including:
* **RAGbot**: An AI chatbot designed to answer questions about documents.
"""
)
30 changes: 15 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]

name = "FreeStream"
version = "2.0.2"
version = "3.0.0"
description = "An effort to give easy access to generative AI."
authors = ["Daethyra <[email protected]>"]
readme = "README.md"
Expand All @@ -11,7 +11,7 @@ license = "GNU AGPL"
python = ">=3.10,<3.12"

langchain = "^0.1.6"
langchain-openai = "^0.0.5"
langchain-openai = "^0.0.7"
langchain-google-genai = "^0.0.9"
streamlit = "^1.31.1"
unstructured = {extras = ["all-docs"], version = "^0.12.4"}
Expand Down

0 comments on commit c429e2f

Please sign in to comment.