Skip to content

Merge Text2sql micro app into lyzr-example #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions example/Text2Sql/Hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import os
from PIL import Image
import streamlit as st
from lyzr import FormulaGen

# Set OpenAI API key
os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]

# Custom function to style the app
def style_app():
# You can put your CSS styles here
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; }
.button-group { display: flex; justify-content: space-between; }
.button { flex: 1; margin: 0 0.5rem; background-color: #4CAF50; color: white; border: none; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; transition-duration: 0.4s; cursor: pointer; border-radius: 12px; }
.button:hover { background-color: #45a049; }
.button:active { background-color: #3e8e41; transform: translateY(2px); }
.input-text { padding: 10px; border-radius: 12px; border: 1px solid #ccc; width: 100%; box-sizing: border-box; margin-bottom: 10px; }
.input-text:focus { border-color: #4CAF50; }
</style>
""", unsafe_allow_html=True)

# Call the function to apply the styles
style_app()

# Load and display the logo
image = Image.open("lyzr-logo.png")
st.image(image, width=150)

# App title and introduction
st.title("QueryGenius (Built using Lyzr SDK)")
st.markdown("### Welcome to QueryGenius!⌨️")
st.markdown("Transform your descriptions into SQL queries effortlessly and efficiently.")
# Define FormulaGen instance
generate = FormulaGen()

# Define the Streamlit app layout
def app():

# Text input for user to input the text
text_input = st.text_area("Enter your texts:")

# Button to trigger the conversion
if st.button("Convert to SQL"):
# Text to SQL conversion
result = generate.text_to_sql(text_input)

# Display the result
st.subheader("Generated SQL Query:")
st.code(result, language="sql")


# Run the app
if __name__ == "__main__":
app()

# Footer or any additional information
with st.expander("ℹ️ - About this App"):
st.markdown("""
QueryGenius is an intuitive web application that effortlessly converts natural language descriptions into SQL queries, streamlining the querying process and eliminating manual construction.
""")

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)
1 change: 1 addition & 0 deletions example/Text2Sql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
QueryGenius is an intuitive web application designed to simplify the process of converting natural language descriptions into SQL queries. With QueryGenius, users can effortlessly transform their textual descriptions of data requirements into SQL queries, streamlining the querying process and eliminating the need for manual query construction.
Binary file added example/Text2Sql/lyzr-logo-cut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/Text2Sql/lyzr-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions example/Text2Sql/packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
libnss3
libnspr4
libatk1.0-0
libatk-bridge2.0-0
libcups2
libdrm2
libxkbcommon0
libxcomposite1
libxdamage1
libxfixes3
libxrandr2
libgbm1
libpango-1.0-0
libcairo2
libasound2
libatspi2.0-0
libwayland-client0
104 changes: 104 additions & 0 deletions example/Text2Sql/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
aiohttp==3.9.3
aiosignal==1.3.1
aiostream==0.5.2
altair==5.2.0
annotated-types==0.6.0
anyio==3.7.1
appdirs==1.4.4
asyncio==3.4.3
attrs==23.2.0
Authlib==1.3.0
beautifulsoup4==4.12.2
blinker==1.7.0
cachetools==5.3.3
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
contourpy==1.2.0
cryptography==42.0.5
cycler==0.12.1
dataclasses-json==0.5.14
Deprecated==1.2.14
distro==1.9.0
filelock==3.13.1
fonttools==4.49.0
frozenlist==1.4.1
fsspec==2024.2.0
gitdb==4.0.11
GitPython==3.1.41
greenlet==3.0.3
h11==0.14.0
httpcore==1.0.4
httpx==0.27.0
huggingface-hub==0.21.4
idna==3.6
importlib_metadata==7.0.2
Jinja2==3.1.3
joblib==1.3.2
jsonpatch==1.33
jsonpointer==2.4
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
kiwisolver==1.4.5
langchain==0.0.339
langsmith==0.0.92
litellm==1.2.0
llama-index==0.9.4
llmsherpa==0.1.4
lyzr==0.1.25
markdown-it-py==3.0.0
MarkupSafe==2.1.5
marshmallow==3.21.1
mdurl==0.1.2
multidict==6.0.5
mypy-extensions==1.0.0
nest-asyncio==1.6.0
nltk==3.8.1
numpy==1.26.4
openai==1.3.4
packaging==23.2
pandas==2.0.2
pillow==10.2.0
playwright==1.42.0
protobuf==4.25.3
pyarrow==15.0.1
pycparser==2.21
pydantic==2.6.4
pydantic_core==2.16.3
pydeck==0.8.1b0
pyee==11.0.1
Pygments==2.17.2
pyparsing==3.1.2
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.1
PyYAML==6.0.1
referencing==0.33.0
regex==2023.12.25
requests==2.31.0
rich==13.7.1
rpds-py==0.18.0
six==1.16.0
smmap==5.0.1
sniffio==1.3.1
soupsieve==2.5
SQLAlchemy==2.0.28
streamlit==1.32.2
tenacity==8.2.3
tiktoken==0.6.0
tokenizers==0.15.2
toml==0.10.2
toolz==0.12.1
tornado==6.4
tqdm==4.66.2
typing-inspect==0.9.0
typing_extensions==4.10.0
tzdata==2024.1
urllib3==1.26.18
validators==0.22.0
watchdog==4.0.0
weaviate-client==3.25.3
wrapt==1.16.0
yarl==1.9.4
zipp==3.18.1