-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from soumyabhardwaj/main
RecipeAdvisor
- Loading branch information
Showing
6 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# streamlit variable | ||
.streamlit/secrets.toml | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
from PIL import Image | ||
import streamlit as st | ||
import openai | ||
import os | ||
import time | ||
from lyzr import ChatBot | ||
from dotenv import load_dotenv; load_dotenv() | ||
|
||
st.set_page_config( | ||
page_title="Recipe Advisor", | ||
layout="centered", # or "wide" | ||
initial_sidebar_state="auto", | ||
page_icon="logo\lyzr-logo-cut.png", | ||
) | ||
|
||
st.markdown( | ||
""" | ||
<style> | ||
.app-header { visibility: hidden; } | ||
.css-18e3th9 { padding-top: 0; padding-bottom: 0; } | ||
.css-1d391kg { padding-top: 1rem; padding-right: 1rem; padding-bottom: 1rem; padding-left: 1rem; } | ||
</style> | ||
""", | ||
unsafe_allow_html=True, | ||
) | ||
|
||
|
||
# Load and display the logo | ||
image = Image.open("logo/lyzr-logo.png") | ||
st.image(image, width=150) | ||
|
||
# App title and introduction | ||
st.title("Recipe Advisor") | ||
st.markdown("### Welcome to the Lyzr Recipe Bot!") | ||
|
||
|
||
# Initialize openai api key | ||
os.environ["OPENAI_API_KEY"] = os.getenv('OPENAI_API_KEY') | ||
|
||
|
||
# Generate a unique index name based on the current timestamp | ||
unique_index_name = f"IndexName_{int(time.time())}" | ||
vector_store_params = {"index_name": unique_index_name} | ||
st.session_state["chatbot"] = ChatBot.pdf_chat( | ||
input_files=["dinnerRecipe.pdf"], vector_store_params=vector_store_params | ||
) | ||
|
||
# # Inform the user that the files have been uploaded and processed | ||
# st.success("PDFs uploaded and processed. You can now interact with the chatbot.") | ||
|
||
|
||
if "messages" not in st.session_state: | ||
st.session_state.messages = [] | ||
|
||
|
||
for message in st.session_state.messages: | ||
with st.chat_message(message["role"]): | ||
st.markdown(message["content"]) | ||
|
||
if "chatbot" in st.session_state: | ||
if prompt := st.chat_input("What is up?"): | ||
st.session_state.messages.append({"role": "user", "content": prompt}) | ||
with st.chat_message("user"): | ||
st.markdown(prompt) | ||
|
||
with st.chat_message("assistant"): | ||
response = st.session_state["chatbot"].chat(prompt) | ||
chat_response = response.response | ||
response = st.write(chat_response) | ||
st.session_state.messages.append( | ||
{"role": "assistant", "content": chat_response} | ||
) | ||
else: | ||
st.warning("Please upload PDF files to continue.") | ||
|
||
|
||
# Footer or any additional information | ||
with st.expander("ℹ️ - About this App"): | ||
st.markdown( | ||
""" | ||
This app uses Lyzr ChatBot. It gives you multiple suggestion for the recipes that can be cooked using available ingredients you have. For any inquiries or issues, please contact Lyzr. | ||
""" | ||
) | ||
st.link_button("Lyzr", url="https://www.lyzr.ai/", use_container_width=True) | ||
st.link_button( | ||
"Book a Demo", url="https://www.lyzr.ai/book-demo/", use_container_width=True | ||
) | ||
st.link_button( | ||
"Discord", url="https://discord.gg/nm7zSyEFA2", use_container_width=True | ||
) | ||
st.link_button( | ||
"Slack", | ||
url="https://join.slack.com/t/genaiforenterprise/shared_invite/zt-2a7fr38f7-_QDOY1W1WSlSiYNAEncLGw", | ||
use_container_width=True, | ||
) |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.