Skip to content

Commit

Permalink
clean old naming
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkolo committed Sep 16, 2024
1 parent 8a1cb7f commit 8f16816
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 30 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
![Docker-Badge](https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge&logo=docker&logoColor=white)
<!--- BADGES: END --->

# Nutrify Your Life: A Science-Based Health & Lifestyle Companion 🥦
# 🥦 Nutrify Your Life 🥦

## A RAG-based Q&A chatbot
## A Science-Based Health & Lifestyle Companion

**Nutrify Your Life** is your personal digital assistant, inspired by the science-based expertise of [NutritionFacts.org](https://nutritionfacts.org/about/). Designed to answer your questions about healthy eating and lifestyle choices, this assistant draws from over 1,200 well-researched blog posts since 2011. Whether you're looking for nutrition tips or guidance on living a healthier life, it offers reliable, science-backed insights to help you live a healthier, more informed life.
### (a RAG-based Q&A chatbot)

Start chatting with the **Nutrify Your Life** companion [here](https://dr-greger-blog-bot.streamlit.app/).
**Nutrify Your Life** is your personal companion, inspired by the science-based expertise of [NutritionFacts.org](https://nutritionfacts.org/about/). Designed to answer your questions about healthy eating and lifestyle choices, this AI-powered digital assistant draws from over 1,200 well-researched blog posts since 2011. Whether you're looking for nutrition tips or guidance on living a healthier life, it offers reliable, science-backed insights to help you live a healthier, more informed life.

Start chatting with the **Nutrify Your Life** companion [here](https://nutrify-your-life.streamlit.app/).

<!---
<p align="center">
<a href="https://dr-greger-blog-bot.streamlit.app/" target="_blank">
<a href="https://nutrify-your-life.streamlit.app/" target="_blank">
<img src="data/images/app_screenshot_2024-09-10.png" width="400">
</a>
</p>
Expand Down
13 changes: 7 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from lancedb.table import Table as KBaseTable

import src.constants as cst
from src.app_utils import connect_to_llm, init_st_keys, load_image
from src.app_utils import connect_to_llm, init_st_keys
from src.app_widgets import create_button, create_chat_msg, create_first_assistant_msg, show_chat_history, show_md_file
from src.llm_api import build_full_llm_chat_input, stream_chat_response
from src.mongodb import MongodbClient, get_mongodb_config, save_chat_history
Expand All @@ -29,8 +29,8 @@

# Chat Parameters
# -----------------------------
BOT_AVATAR = load_image(cst.BOT_AVATAR)
chat_config: dict[str, Any] = cst.get_rag_config()["chat"]
BOT_AVATAR: str = chat_config["bot_avatar"]
AVATARS: dict[str, Any] = {"assistant": BOT_AVATAR, "user": chat_config["user_avatar"]}
STREAM_DEFAULT: bool = chat_config["stream_default"]
CHAT_HISTORY_HEIGHT: int = chat_config["chat_history_height"]
Expand Down Expand Up @@ -154,14 +154,15 @@ def process_user_input(

# Page starts here
# ==========================
page_title = "Nutrify Your Life: A Science-Based Health & Lifestyle Companion 🥦"
st.set_page_config(page_title=page_title, page_icon=BOT_AVATAR) # , layout="wide")
page_title = f"Nutrify Your Life {BOT_AVATAR}"
st.set_page_config(page_title=page_title, page_icon=BOT_AVATAR)

# Header
# ------------
st.header(page_title, divider="blue")
st.header(f"{BOT_AVATAR} {page_title}", divider=False)
st.subheader("A Science-Based Health & Lifestyle Companion ", divider="blue")
app_intro: str = """
"Nutrify Your Life" is your personal digital assistant, inspired by the science-based expertise of [NutritionFacts.org](https://nutritionfacts.org/about/). Designed to answer your questions about healthy eating and lifestyle choices, this assistant draws from over 1,200 well-researched blog posts since 2011. Whether you're looking for nutrition tips or guidance on living a healthier life, it offers reliable, science-backed insights to help you live a healthier, more informed life.
"Nutrify Your Life" is your personal companion, inspired by the science-based expertise of [NutritionFacts.org](https://nutritionfacts.org/about/). Designed to answer your questions about healthy eating and lifestyle choices, this AI-powered digital assistant draws from over 1,200 well-researched blog posts since 2011. Whether you're looking for nutrition tips or guidance on living a healthier life, it offers reliable, science-backed insights to help you live a healthier, more informed life.
"""
if not st.session_state["start_chat"]:
st.info(app_intro, icon="💡")
Expand Down
6 changes: 3 additions & 3 deletions dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ def get_values_from_query_file(

# Page starts here
# ==========================
page_title = 'Data Usage of "Nutrition Insights with Dr. Greger\'s Digital Twin 🥦" App'
st.set_page_config(page_title=page_title)
page_title = 'Data Usage of the "Nutrify Your Life" App'
st.set_page_config(page_title=page_title, icon="📊")

# Header
# -------------------------
st.title("Dashboard")
st.header(page_title)
if DEPLOYED:
st.write("Link to app: https://dr-greger-blog-bot.streamlit.app")
st.write("Link to app: https://nutrify-your-life.streamlit.app")
else:
st.write("Link to app: http://localhost:8501")

Expand Down
2 changes: 1 addition & 1 deletion docs/internal_how_to_build.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# How I build this bot

- As I'm interest in living health and healthy lives and very much the [blog post of Dr. Greger](https://nutritionfacts.org/blog/), I decided to build a bot based on this well researched blog posts.
- As I'm interest in living health and healthy lives and very much the [blog post of nutritionfacts.org](https://nutritionfacts.org/blog/), I decided to build a bot based on this well researched blog posts.

## Data Acquisition

Expand Down
4 changes: 2 additions & 2 deletions docs/internal_project_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a RAG-based Q&A Chatbot about healthy eating & lifestyle habits

This is a chatbot intended to help answer questions around a healthy eating and lifestyle habits.

This chatbot (aka digital twin of the physician [Dr. Michael Greger & his team](https://nutritionfacts.org/team/)) will help answer any question you may have about healthy eating and living from the perspective of the science-based nonprofit organization [NUTRITIONFACTS.ORG](https://nutritionfacts.org/about/), which has over 1200 well-researched blog posts since 2011.
This chatbot (aka digital twin of the [nutritionfacts.org team](https://nutritionfacts.org/team/)) will help answer any question you may have about healthy eating and living from the perspective of the science-based nonprofit organization [NUTRITIONFACTS.ORG](https://nutritionfacts.org/about/), which has over 1200 well-researched blog posts since 2011.

## Questions

Expand Down Expand Up @@ -44,7 +44,7 @@ This chatbot (aka digital twin of the physician [Dr. Michael Greger & his team](

Access to reliable and accurate information on healthy eating and lifestyle habits is a significant challenge for the general public. Although many individuals seek to improve their health by making informed choices, they often face obstacles in obtaining trustworthy advice. The internet is saturated with conflicting and sometimes misleading information, making it difficult for non-medical professionals to discern the quality and credibility of the sources. Additionally, accessing professional advice typically requires scheduling appointments with healthcare providers, which can be time-consuming and costly.

This project aims to bridge this gap by providing a RAG-based Q&A chatbot that offers reliable, science-backed answers to questions related to healthy eating and lifestyle habits. The chatbot serves as a digital twin of Dr. Michael Greger and his team at NutritionFacts.org, a well-respected, science-based nonprofit organization dedicated to sharing evidence-based insights on nutrition. By leveraging over 1,200 thoroughly researched blog posts, this chatbot empowers users to obtain accurate and actionable information easily.
This project aims to bridge this gap by providing a RAG-based Q&A chatbot that offers reliable, science-backed answers to questions related to healthy eating and lifestyle habits. The chatbot serves as a digital twin of the team at NutritionFacts.org, a well-respected, science-based nonprofit organization dedicated to sharing evidence-based insights on nutrition. By leveraging over 1,200 thoroughly researched blog posts, this chatbot empowers users to obtain accurate and actionable information easily.

The primary goal of this project is to educate individuals about healthy living, enabling them to make informed decisions that could lead to healthier, happier lives with reduced reliance on medical interventions. In the long term, widespread use of this tool could contribute to alleviating the burden on the healthcare system by promoting preventative health practices.

Expand Down
2 changes: 1 addition & 1 deletion docs/offical_project_description.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This problem is crucial for several reasons:

## Proposed Solution

To address this problem, we are developing a RAG-based (Retrieval-Augmented Generation) Q&A Chatbot focused on healthy eating and lifestyle habits. This chatbot will serve as a digital twin of Dr. Michael Greger and his team from the science-based nonprofit organization NUTRITIONFACTS.ORG.
To address this problem, we are developing a RAG-based (Retrieval-Augmented Generation) Q&A Chatbot focused on healthy eating and lifestyle habits. This chatbot will serve as a digital twin of the team from the science-based nonprofit organization NUTRITIONFACTS.ORG.

Key features of the solution include:

Expand Down
1 change: 1 addition & 0 deletions rag_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ reranker.model_name = "cross-encoder/ms-marco-MiniLM-L-2-v2"

[chat]
user_avatar = ""
bot_avatar = "🥦"
stream_default = true
chat_history_height = 650

Expand Down
25 changes: 13 additions & 12 deletions src/prompt_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

BOT_INSTRUCTION: str = """
<instruction>
You are a digital twin of Dr. Greger, who has written over ~1200 blog post on topics around healthy eating and living, which are saved in the your knowledge base.
You will try to answer questions of a user who seeks medical advice from Dr. Greger.
Keep the response concise.
Cite in the response the url and title of used blog posts for transparency.
Rely solely on the information provided and refrain from making assumptions, making things up, or referring to outside sources.
Always mention that it's important for serious it;s important to seek medical advice from professionals.
If you don't know the answer, say you don't know.
You are a digital assistant drawing from over 1,200 blog posts written by Dr. Greger and his team on topics related to healthy eating and living, all stored in your knowledge base.
Your goal is to provide concise, helpful answers to users seeking guidance on these topics.
Always cite the blog post titles and URLs you reference using markdown syntax for transparency.
Feel free to sprinkle in a few emojis to keep the conversation light and engaging.
Use only the information available in your knowledge base. Avoid making assumptions, referring to external sources, or generating information not explicitly provided.
Remind users that for serious health concerns, it's essential to consult a medical professional.
If you don't know the answer, simply say so.
</instruction>
"""


CONTEXT_TEMPLATE: str = """
<context>
Here is a list of blog posts and their relevant paragraphs that have been retrieved from your knowledge base based on the most recent message posted by the user:
Expand All @@ -23,11 +27,8 @@


WELCOME_MSG: str = """
Hi **{user_name}**! 🌟 Welcome to your personal guide on healthy eating and lifestyle habits. I'm here to help you
navigate the world of nutrition with science-backed insights from
[Dr. Michael Greger & his team](https://nutritionfacts.org/team/)
at [NutritionFacts.org](https://nutritionfacts.org/about/). Whether you have a quick question or need detailed advice,
I'm ready to assist you on your journey to a healthier, happier life. Let's get started! 💚
Hi **{user_name}**! 🌟 Welcome to your personalized guide for healthy eating and lifestyle habits! I'm here to provide you with science-backed insights straight from the vast knowledge base of [Dr. Michael Greger & his team](https://nutritionfacts.org/team/)
at [NutritionFacts.org](https://nutritionfacts.org/about/). Whether you're curious about nutrition, seeking advice, or just looking to make informed choices, I'm here to support you every step of the way on your journey to a healthier, happier life. Let's dive in! 💚
"""


Expand Down

0 comments on commit 8f16816

Please sign in to comment.