diff --git a/examples/Assessment-Generator[QABot]/.gitignore b/examples/Assessment-Generator[QABot]/.gitignore new file mode 100644 index 0000000..4da54a8 --- /dev/null +++ b/examples/Assessment-Generator[QABot]/.gitignore @@ -0,0 +1,161 @@ +# 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/ +litellm_uuid.txt + +# 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/ diff --git a/examples/Assessment-Generator[QABot]/README.md b/examples/Assessment-Generator[QABot]/README.md new file mode 100644 index 0000000..d17cee9 --- /dev/null +++ b/examples/Assessment-Generator[QABot]/README.md @@ -0,0 +1,32 @@ +# Welcome to the Assessment Generator by Lyzr! + +![Lyzr Logo](./logo/lyzr-logo.png) + +In this Assessment Generator you can upload any textbook PDF, specify the subject and major topics, and instantly generate 10 insightful questions per topic using an AI-powered QA bot Agent from Lyzr SDK. + + +*Note: For this application to function properly in your local system, ensure that the required dependencies are installed and configured correctly, and make sure that you have your OpenAI API Key.* + +### Create Virtual Environment +- `python3 -m venv venv` - Ubuntu/MacOs +- `python -m venv venv` - Windows + +### Activate the environment +- `source venv/bin/activate` - Ubuntu/MaOS +- `venv/Script/acitvate` - Windows + +### Installing Dependencies +- `pip3 install -r requirements.txt`- Ubuntu/MacOs +- `pip install -r requirements.txt` - Windows + + +### Run the application on local server +`streamlit run app.py` + +# About Lyzr +Lyzr is a low-code agent framework that follows an **‘agentic’** way to build LLM apps, contrary to Langchain’s ‘functions and chains’ way and DSPy’s ‘programmatic’ way of building LLM apps. + +- [Lyzr](https://www.lyzr.ai/) +- [Book a Demo](https://www.lyzr.ai/book-demo/) +- [Discord](https://discord.gg/nm7zSyEFA2) +- [Slack](https://join.slack.com/t/genaiforenterprise/shared_invite/zt-2a7fr38f7-_QDOY1W1WSlSiYNAEncLGw) diff --git a/examples/Assessment-Generator[QABot]/app.py b/examples/Assessment-Generator[QABot]/app.py new file mode 100644 index 0000000..53d12e4 --- /dev/null +++ b/examples/Assessment-Generator[QABot]/app.py @@ -0,0 +1,98 @@ +import os +from PIL import Image +from utils import utils +import streamlit as st +from dotenv import load_dotenv; load_dotenv() +from lyzr import QABot + +# Setup your config +st.set_page_config( + page_title="Assesement Generator", + layout="centered", # or "wide" + initial_sidebar_state="auto", + page_icon="./logo/lyzr-logo-cut.png" +) + +# Load and display the logo +image = Image.open("./logo/lyzr-logo.png") +st.image(image, width=150) + +# App title and introduction +st.title("Assesement Generator by Lyzr") +st.markdown("### Welcome to the Assesement Generator!") +st.markdown("Assesement Generator by Lyzr will provide you 10 insightful questions on the textbook pdf you have uploaded") + +# Custom function to style the app +def style_app(): + # You can put your CSS styles here + st.markdown(""" + + """, unsafe_allow_html=True) + +# Assesement Generator Application + +# replace this with your openai api key or create an environment variable for storing the key. +os.environ["OPENAI_API_KEY"] = os.getenv('OPENAI_API_KEY') + + +# create directory if it doesn't exist +data = "data" +os.makedirs(data, exist_ok=True) + + + +def vector_store_configuration(bookname): + vector_store_params = { + "vector_store_type": "WeaviateVectorStore", + "url": os.getenv('VECTOR_STORE_URL'), # replce the url with your weaviate cluster url + "api_key": os.getenv('VECTOR_STORE_API'), # replace the api with your weaviate cluster api + "index_name": f"Book{bookname}IndexName" + } + + return vector_store_params + + +def smartstudy_bot(filepath, vector_params): + "This function will implement the Lyzr's QA agent to summarize the Youtube Video" + smartstudy = QABot.pdf_qa( + input_files=[str(filepath)], + vector_store_params=vector_params + ) + + return smartstudy + +if __name__ == "__main__": + style_app() + uploaded_file = st.file_uploader("Choose PDF file", type=["pdf"]) + if uploaded_file is not None: + filename = utils.save_uploaded_file(uploaded_file) + subject_name = st.text_input("Write the subject of your Book") + topics = st.text_input("Enter topics (by comma seperated)") + topics_list = [topic.strip() for topic in topics.split(",") if topic.strip()] + + if topics_list is not None: + if st.button("Generate"): + path = utils.get_files_in_directory(data) + filepath = path[0] + vector_params = vector_store_configuration(filename) + study_agent = smartstudy_bot(filepath=filepath, vector_params=vector_params) + if study_agent is not None: + topic_response = utils.user_subject_topics(agent=study_agent, subject=subject_name, topics_lst=topics_list) + utils.flashcard_viewer(response=topic_response) + else: + utils.remove_existing_files(data) + st.warning('Please Upload pdf file') + + with st.expander("ℹ️ - About this App"): + st.markdown(""" + This app uses Lyzr QABot agent to 10 qustions from TextBook pdf. The QABot agent is built on the powerful Retrieval-Augmented Generation (RAG) model, enhancing your ability to extract valuable insights. 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) \ No newline at end of file diff --git a/examples/Employee_HR_QnA/lyzr-logo-cut.png b/examples/Assessment-Generator[QABot]/logo/lyzr-logo-cut.png similarity index 100% rename from examples/Employee_HR_QnA/lyzr-logo-cut.png rename to examples/Assessment-Generator[QABot]/logo/lyzr-logo-cut.png diff --git a/examples/Employee_HR_QnA/lyzr-logo.png b/examples/Assessment-Generator[QABot]/logo/lyzr-logo.png similarity index 100% rename from examples/Employee_HR_QnA/lyzr-logo.png rename to examples/Assessment-Generator[QABot]/logo/lyzr-logo.png diff --git a/examples/Assessment-Generator[QABot]/requirements.txt b/examples/Assessment-Generator[QABot]/requirements.txt new file mode 100644 index 0000000..4f2e108 Binary files /dev/null and b/examples/Assessment-Generator[QABot]/requirements.txt differ diff --git a/examples/Employee_HR_QnA/utils/__init__.py b/examples/Assessment-Generator[QABot]/utils/__init__.py similarity index 100% rename from examples/Employee_HR_QnA/utils/__init__.py rename to examples/Assessment-Generator[QABot]/utils/__init__.py diff --git a/examples/Assessment-Generator[QABot]/utils/utils.py b/examples/Assessment-Generator[QABot]/utils/utils.py new file mode 100644 index 0000000..f63b6d5 --- /dev/null +++ b/examples/Assessment-Generator[QABot]/utils/utils.py @@ -0,0 +1,71 @@ +import os +import shutil +import streamlit as st +from pathlib import Path +import pandas as pd + +def remove_existing_files(directory): + for filename in os.listdir(directory): + file_path = os.path.join(directory, filename) + try: + if os.path.isfile(file_path) or os.path.islink(file_path): + os.unlink(file_path) + elif os.path.isdir(file_path): + shutil.rmtree(file_path) + except Exception as e: + st.error(f"Error while removing existing files: {e}") + + +def get_files_in_directory(directory): + # This function help us to get the file path along with filename. + files_list = [] + + if os.path.exists(directory) and os.path.isdir(directory): + for filename in os.listdir(directory): + file_path = os.path.join(directory, filename) + + if os.path.isfile(file_path): + files_list.append(file_path) + + return files_list + +def save_uploaded_file(uploaded_file): + # Function to save uploaded file + remove_existing_files('data') + + file_path = os.path.join('data', uploaded_file.name) + with open(file_path, "wb") as file: + file.write(uploaded_file.read()) + st.success("File uploaded successfully") + + rev = uploaded_file.name[::-1] + rev = rev[4:] + filename = rev[::-1] + + return filename[:3] + + +def user_subject_topics(agent, subject, topics_lst): + resposne_flash = {} + for topic in topics_lst: + prompt = f"""You are an expert of this {subject}, Can you write down 3-5 important questions on this {subject} and its topics: {topic} """ + response = agent.query(prompt) + if response is not None: + if response.response == 'Empty Response': + st.warning('Please provide valid pdf') + + elif response.response != 'Empty Response': + # st.subheader("These are the Important Questions, you should prepare") + # st.write(response.response) + resposne_flash[topic] = response.response.split('?') + + return resposne_flash + + +def flashcard_viewer(response:dict): + for topic, questions in response.items(): + st.subheader(topic) + for question in questions: + st.write(question) + st.markdown("---") + diff --git a/examples/Employee_HR_QnA/.gitignore b/examples/Employee-HR-Bot[QABot]/.gitignore similarity index 100% rename from examples/Employee_HR_QnA/.gitignore rename to examples/Employee-HR-Bot[QABot]/.gitignore diff --git a/examples/Employee_HR_QnA/README.md b/examples/Employee-HR-Bot[QABot]/README.md similarity index 100% rename from examples/Employee_HR_QnA/README.md rename to examples/Employee-HR-Bot[QABot]/README.md diff --git a/examples/Employee_HR_QnA/app.py b/examples/Employee-HR-Bot[QABot]/app.py similarity index 100% rename from examples/Employee_HR_QnA/app.py rename to examples/Employee-HR-Bot[QABot]/app.py diff --git a/examples/Resume_QnA/lyzr-logo-cut.png b/examples/Employee-HR-Bot[QABot]/lyzr-logo-cut.png similarity index 100% rename from examples/Resume_QnA/lyzr-logo-cut.png rename to examples/Employee-HR-Bot[QABot]/lyzr-logo-cut.png diff --git a/examples/Resume_QnA/lyzr-logo.png b/examples/Employee-HR-Bot[QABot]/lyzr-logo.png similarity index 100% rename from examples/Resume_QnA/lyzr-logo.png rename to examples/Employee-HR-Bot[QABot]/lyzr-logo.png diff --git a/examples/Employee_HR_QnA/requirements.txt b/examples/Employee-HR-Bot[QABot]/requirements.txt similarity index 100% rename from examples/Employee_HR_QnA/requirements.txt rename to examples/Employee-HR-Bot[QABot]/requirements.txt diff --git a/examples/Employee-HR-Bot[QABot]/utils/__init__.py b/examples/Employee-HR-Bot[QABot]/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/Employee_HR_QnA/utils/utils.py b/examples/Employee-HR-Bot[QABot]/utils/utils.py similarity index 100% rename from examples/Employee_HR_QnA/utils/utils.py rename to examples/Employee-HR-Bot[QABot]/utils/utils.py diff --git a/examples/Event-Planning-Assistant[QABot]/.gitignore b/examples/Event-Planning-Assistant[QABot]/.gitignore new file mode 100644 index 0000000..1e37816 --- /dev/null +++ b/examples/Event-Planning-Assistant[QABot]/.gitignore @@ -0,0 +1,162 @@ +# 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/ + +# 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/ + +litellm_uuid.txt \ No newline at end of file diff --git a/examples/Event-Planning-Assistant[QABot]/README.md b/examples/Event-Planning-Assistant[QABot]/README.md new file mode 100644 index 0000000..f5f34cb --- /dev/null +++ b/examples/Event-Planning-Assistant[QABot]/README.md @@ -0,0 +1,32 @@ +# Welcome to the Event Planning QnA by Lyzr! + +![Lyzr Logo](./logo/lyzr-logo.png) + +Event planners is build on a QABot Agent to answer attendee questions. Attendees could ask questions about schedules, locations, speakers, or logistics and the bot would answer using event information or connect them with organizers. + + +*Note: For this application to function properly in your local system, ensure that the required dependencies are installed and configured correctly, and make sure that you have your OpenAI API Key.* + +### Create Virtual Environment +- `python3 -m venv venv` - Ubuntu/MacOs +- `python -m venv venv` - Windows + +### Activate the environment +- `source venv/bin/activate` - Ubuntu/MaOS +- `venv/Script/acitvate` - Windows + +### Installing Dependencies +- `pip3 install -r requirements.txt`- Ubuntu/MacOs +- `pip install -r requirements.txt` - Windows + + +### Run the application on local server +`streamlit run app.py` + +# About Lyzr +Lyzr is a low-code agent framework that follows an **‘agentic’** way to build LLM apps, contrary to Langchain’s ‘functions and chains’ way and DSPy’s ‘programmatic’ way of building LLM apps. + +- [Lyzr](https://www.lyzr.ai/) +- [Book a Demo](https://www.lyzr.ai/book-demo/) +- [Discord](https://discord.gg/nm7zSyEFA2) +- [Slack](https://join.slack.com/t/genaiforenterprise/shared_invite/zt-2a7fr38f7-_QDOY1W1WSlSiYNAEncLGw) \ No newline at end of file diff --git a/examples/Event-Planning-Assistant[QABot]/app.py b/examples/Event-Planning-Assistant[QABot]/app.py new file mode 100644 index 0000000..bbe8cd9 --- /dev/null +++ b/examples/Event-Planning-Assistant[QABot]/app.py @@ -0,0 +1,83 @@ +import os +from PIL import Image +import streamlit as st +from pathlib import Path +from utils import utils +from dotenv import load_dotenv; load_dotenv() +from lyzr import QABot + +# Setup your config +st.set_page_config( + page_title="Event Planner", + layout="centered", # or "wide" + initial_sidebar_state="auto", + page_icon="./logo/lyzr-logo-cut.png" +) + +# Load and display the logo +image = Image.open("./logo/lyzr-logo.png") +st.image(image, width=150) + +# App title and introduction +st.title("Event Planner QnA by Lyzr") +st.markdown("### Welcome to the Event Planner QnA!") +st.markdown("Event planners is build on a QABot Agent to answer attendee questions. Attendees could ask questions about schedules, locations, speakers, or logistics") + +# Custom function to style the app +def style_app(): + # You can put your CSS styles here + st.markdown(""" + + """, unsafe_allow_html=True) + +# Event Planner QnA Application + +# replace this with your openai api key or create an environment variable for storing the key. +os.environ["OPENAI_API_KEY"] = os.getenv('OPENAI_API_KEY') + + +def event_planner_qa(): + path = utils.get_files_in_directory('data') + planner_qa = QABot.docx_qa( + input_files=[Path(str(path[1]))] + ) + + return planner_qa + +def file_checker(): + file = [] + for filename in os.listdir('data'): + file_path = os.path.join('data', filename) + file.append(file_path) + + return file + +if __name__ == "__main__": + style_app() + file = file_checker() + if file is not None: + st.subheader('Plan your dream event!') + question = st.text_input('Write you query') + if st.button('Submit'): + if question is not None: + event_agent = event_planner_qa() + response = event_agent.query(question) + st.markdown('---') + st.subheader('Response') + st.write(response.response) + else: + st.warning("Ask question, don't keep it blank") + + with st.expander("ℹ️ - About this App"): + st.markdown(""" + This app uses Lyzr QABot agent to give answer attendee questions. The QABot agent is built on the powerful Retrieval-Augmented Generation (RAG) model, enhancing your ability to extract valuable insights. 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) \ No newline at end of file diff --git a/examples/Event-Planning-Assistant[QABot]/data/Event Planner Assistnace.docx b/examples/Event-Planning-Assistant[QABot]/data/Event Planner Assistnace.docx new file mode 100644 index 0000000..dc97491 Binary files /dev/null and b/examples/Event-Planning-Assistant[QABot]/data/Event Planner Assistnace.docx differ diff --git a/examples/Event-Planning-Assistant[QABot]/data/__init__.py b/examples/Event-Planning-Assistant[QABot]/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/Event-Planning-Assistant[QABot]/logo/lyzr-logo-cut.png b/examples/Event-Planning-Assistant[QABot]/logo/lyzr-logo-cut.png new file mode 100644 index 0000000..5667dd7 Binary files /dev/null and b/examples/Event-Planning-Assistant[QABot]/logo/lyzr-logo-cut.png differ diff --git a/examples/Event-Planning-Assistant[QABot]/logo/lyzr-logo.png b/examples/Event-Planning-Assistant[QABot]/logo/lyzr-logo.png new file mode 100644 index 0000000..090c292 Binary files /dev/null and b/examples/Event-Planning-Assistant[QABot]/logo/lyzr-logo.png differ diff --git a/examples/Event-Planning-Assistant[QABot]/requirements.txt b/examples/Event-Planning-Assistant[QABot]/requirements.txt new file mode 100644 index 0000000..6016af9 Binary files /dev/null and b/examples/Event-Planning-Assistant[QABot]/requirements.txt differ diff --git a/examples/Event-Planning-Assistant[QABot]/utils/utils.py b/examples/Event-Planning-Assistant[QABot]/utils/utils.py new file mode 100644 index 0000000..3886a1f --- /dev/null +++ b/examples/Event-Planning-Assistant[QABot]/utils/utils.py @@ -0,0 +1,15 @@ +import os + + +def get_files_in_directory(directory): + # This function help us to get the file path along with filename. + files_list = [] + + if os.path.exists(directory) and os.path.isdir(directory): + for filename in os.listdir(directory): + file_path = os.path.join(directory, filename) + + if os.path.isfile(file_path): + files_list.append(file_path) + + return files_list \ No newline at end of file diff --git a/examples/Resume_QnA/.gitignore b/examples/Interactive-Audiobook[VoiceBot]/.gitignore similarity index 100% rename from examples/Resume_QnA/.gitignore rename to examples/Interactive-Audiobook[VoiceBot]/.gitignore diff --git a/examples/Interactive-Audiobook[VoiceBot]/README.md b/examples/Interactive-Audiobook[VoiceBot]/README.md new file mode 100644 index 0000000..0975e9b --- /dev/null +++ b/examples/Interactive-Audiobook[VoiceBot]/README.md @@ -0,0 +1,32 @@ +# Welcome to the Interactive Audiobook by Lyzr! + +![Lyzr Logo](./logo/lyzr-logo.png) + +This Interactive Audiobook uses Lyzr's Voice bot agent to convert children's stories into interactive audiobooks. VoiceBot's Text-to-Speech function can narrate the text. + + +*Note: For this application to function properly in your local system, ensure that the required dependencies are installed and configured correctly, and make sure that you have your OpenAI API Key.* + +### Create Virtual Environment +- `python3 -m venv venv` - Ubuntu/MacOs +- `python -m venv venv` - Windows + +### Activate the environment +- `source venv/bin/activate` - Ubuntu/MaOS +- `venv/Script/acitvate` - Windows + +### Installing Dependencies +- `pip3 install -r requirements.txt`- Ubuntu/MacOs +- `pip install -r requirements.txt` - Windows + + +### Run the application on local server +`streamlit run app.py` + +# About Lyzr +Lyzr is a low-code agent framework that follows an **‘agentic’** way to build LLM apps, contrary to Langchain’s ‘functions and chains’ way and DSPy’s ‘programmatic’ way of building LLM apps. + +- [Lyzr](https://www.lyzr.ai/) +- [Book a Demo](https://www.lyzr.ai/book-demo/) +- [Discord](https://discord.gg/nm7zSyEFA2) +- [Slack](https://join.slack.com/t/genaiforenterprise/shared_invite/zt-2a7fr38f7-_QDOY1W1WSlSiYNAEncLGw) diff --git a/examples/Interactive-Audiobook[VoiceBot]/app.py b/examples/Interactive-Audiobook[VoiceBot]/app.py new file mode 100644 index 0000000..9fb14bf --- /dev/null +++ b/examples/Interactive-Audiobook[VoiceBot]/app.py @@ -0,0 +1,85 @@ +import os +from PIL import Image +from utils import utils +from pathlib import Path +import streamlit as st +from dotenv import load_dotenv; load_dotenv() +from lyzr import VoiceBot + +# Setup your config +st.set_page_config( + page_title="Interactive Audiobook", + layout="centered", # or "wide" + initial_sidebar_state="auto", + page_icon="./logo/lyzr-logo-cut.png" +) + +# Load and display the logo +image = Image.open("./logo/lyzr-logo.png") +st.image(image, width=150) + +# App title and introduction +st.title("Interactive Audiobook by Lyzr") +st.markdown("### Welcome to the Interactive Audiobook!") +st.markdown("Interactive Audiobook by Lyzr will convert children's stories into interactive audiobook") + +# Custom function to style the app +def style_app(): + # You can put your CSS styles here + st.markdown(""" + + """, unsafe_allow_html=True) + +# Interactive Audiobook Application + +audio_directory = 'audio' +os.makedirs(audio_directory, exist_ok=True) +original_directory = os.getcwd() + +# replace this with your openai api key or create an environment variable for storing the key. +API_KEY = os.getenv('OPENAI_API_KEY') + + +def audiobook_agent(user_story:str): + vb = VoiceBot(api_key=API_KEY) + try: + os.chdir(audio_directory) + vb.text_to_speech(user_story) + finally: + os.chdir(original_directory) + + + +if __name__ == "__main__": + style_app() + topic = st.text_input('Write breif about the story') + if st.button('Create'): + if topic: + prompt = utils.prompt(user_input=topic) + story = utils.story_generator(prompt=prompt) + st.subheader('Glimpse of Story') + shorten_story = story[:450] + st.write(shorten_story) + st.markdown('---') + st.subheader('Story into audiobook') + audiobook_agent(user_story=story) + files = utils.get_files_in_directory(audio_directory) + audio_file = files[0] + st.audio(audio_file) + else: + st.warning("Provide the content for story, don't keep it blank") + + + with st.expander("ℹ️ - About this App"): + st.markdown(""" + This app uses Lyzr Voice Bot agent to convert books into interactive audiobooks. The QABot agent is built on the powerful Retrieval-Augmented Generation (RAG) model, enhancing your ability to extract valuable insights. 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) \ No newline at end of file diff --git a/examples/Interactive-Audiobook[VoiceBot]/logo/lyzr-logo-cut.png b/examples/Interactive-Audiobook[VoiceBot]/logo/lyzr-logo-cut.png new file mode 100644 index 0000000..5667dd7 Binary files /dev/null and b/examples/Interactive-Audiobook[VoiceBot]/logo/lyzr-logo-cut.png differ diff --git a/examples/Interactive-Audiobook[VoiceBot]/logo/lyzr-logo.png b/examples/Interactive-Audiobook[VoiceBot]/logo/lyzr-logo.png new file mode 100644 index 0000000..090c292 Binary files /dev/null and b/examples/Interactive-Audiobook[VoiceBot]/logo/lyzr-logo.png differ diff --git a/examples/Interactive-Audiobook[VoiceBot]/requirements.txt b/examples/Interactive-Audiobook[VoiceBot]/requirements.txt new file mode 100644 index 0000000..c63235b Binary files /dev/null and b/examples/Interactive-Audiobook[VoiceBot]/requirements.txt differ diff --git a/examples/Interactive-Audiobook[VoiceBot]/utils/__init__.py b/examples/Interactive-Audiobook[VoiceBot]/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/Interactive-Audiobook[VoiceBot]/utils/utils.py b/examples/Interactive-Audiobook[VoiceBot]/utils/utils.py new file mode 100644 index 0000000..a28058f --- /dev/null +++ b/examples/Interactive-Audiobook[VoiceBot]/utils/utils.py @@ -0,0 +1,42 @@ +import os +from dotenv import load_dotenv; load_dotenv() +from openai import OpenAI + + + +def get_files_in_directory(directory): + # This function help us to get the file path along with filename. + files_list = [] + + if os.path.exists(directory) and os.path.isdir(directory): + for filename in os.listdir(directory): + file_path = os.path.join(directory, filename) + + if os.path.isfile(file_path): + files_list.append(file_path) + + return files_list + + +def story_generator(prompt): + API_KEY = os.getenv('OPENAI_API_KEY') + ai = OpenAI(api_key=API_KEY) + + response = ai.completions.create( + model="gpt-3.5-turbo-instruct", + prompt=prompt, + temperature=0.1, + max_tokens=1000) + + story = response.choices[0].text.strip() + return story + +def prompt(user_input): + prompt = f"""You are an expert to create kid's stories, create a complete story on this {user_input}. + Make sure story obeys these points: + 1. Story should be short and precise. + 2. Story will cover from introduction to climax in 500-700 words. + 3. Story will proivde valuable learning's for children's. + """ + + return prompt diff --git a/examples/Resume-Bot[QABot]/.gitignore b/examples/Resume-Bot[QABot]/.gitignore new file mode 100644 index 0000000..68bc17f --- /dev/null +++ b/examples/Resume-Bot[QABot]/.gitignore @@ -0,0 +1,160 @@ +# 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/ + +# 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/ diff --git a/examples/Resume_QnA/README.md b/examples/Resume-Bot[QABot]/README.md similarity index 97% rename from examples/Resume_QnA/README.md rename to examples/Resume-Bot[QABot]/README.md index 409197b..f92b38e 100644 --- a/examples/Resume_QnA/README.md +++ b/examples/Resume-Bot[QABot]/README.md @@ -1,4 +1,4 @@ -# Resume_QnA +# CV-QnA-LyzrBot ## Purpose @@ -20,7 +20,7 @@ Follow these steps to run the Lyzr CV QA-Bot Streamlit App locally: 2. **Run the App:** ```bash - streamlit run app.py + streamlit run QAbotapp.py 3. **Provide API Key:** Enter your OpenAI API key in the sidebar to enable Lyzr SDK functionality. diff --git a/examples/Resume_QnA/app.py b/examples/Resume-Bot[QABot]/app.py similarity index 100% rename from examples/Resume_QnA/app.py rename to examples/Resume-Bot[QABot]/app.py diff --git a/examples/Resume-Bot[QABot]/lyzr-logo-cut.png b/examples/Resume-Bot[QABot]/lyzr-logo-cut.png new file mode 100644 index 0000000..5667dd7 Binary files /dev/null and b/examples/Resume-Bot[QABot]/lyzr-logo-cut.png differ diff --git a/examples/Resume-Bot[QABot]/lyzr-logo.png b/examples/Resume-Bot[QABot]/lyzr-logo.png new file mode 100644 index 0000000..090c292 Binary files /dev/null and b/examples/Resume-Bot[QABot]/lyzr-logo.png differ diff --git a/examples/Resume_QnA/requirements.txt b/examples/Resume-Bot[QABot]/requirements.txt similarity index 100% rename from examples/Resume_QnA/requirements.txt rename to examples/Resume-Bot[QABot]/requirements.txt