Streamlit Updates. Assistant
AIssistant Updates
The aissistant was ideated as a some kind of all-in-one tool around LLMs.
Well, not only text centered, but using the multi-model capabilities as well:
And it had quite a few different features.
Do you prefer the box? the plastic?
Or the expensive toy I bought you?
DBChat Assistant
We come from here.
And I could not resist to combine it:
You can think about this is a kind of BI/AI part
Streamlit + DataChat AI / SQL + PyGWalker | Example 📌
streamlit run Z_ST_AIssistant_dbchat_v3b.py
import streamlit as st
from pygwalker.api.streamlit import StreamlitRenderer
from langchain_community.utilities import SQLDatabase
import pandas as pd
import os
from dotenv import load_dotenv
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnablePassthrough
from langchain_openai import ChatOpenAI
st.set_page_config(
page_title="Use Pygwalker In Streamlit",
layout="wide"
)
st.title("SQL Database Table Viewer and Chat")
# Load environment variables
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
from openai import OpenAI
# Initialize the OpenAI client
client = OpenAI(api_key=api_key)
# MySQL URI (replace with your password)
mysql_uri = st.text_input("MySQL URI", "mysql+mysqlconnector://root:your_password@localhost:3306/Chinook")
# Debug Mode
DEBUG_MODE = st.checkbox("Enable Debug Mode (Show SQL Queries)", False)
# Get the list of tables
db = SQLDatabase.from_uri(mysql_uri)
tables_result = db.run("SHOW TABLES;")
tables = [table_tuple[0] for table_tuple in eval(tables_result)]
# Table selection
selected_table = st.selectbox("Select a Table", tables)
if selected_table:
df = load_data_mysql(mysql_uri, selected_table)
if df is not None:
st.write(f"### Data from {selected_table}")
st.dataframe(df)
display_pygwalker(df)
# Chat with Database about the whole database
st.write("### Ask a Question about the Entire Database")
global_question = st.text_input("Global Question", "What are the top 5 artists with more albums published?")
if st.button("Submit Global Question"):
if global_question:
response, sql_query = chat_with_database(mysql_uri, global_question)
st.write("Global Response:", response)
if DEBUG_MODE and sql_query:
with st.expander("SQL Query"):
st.code(sql_query, language="sql")
else:
st.warning("Please enter a global question.")
# Interactive SQL Query Section
with st.expander("Run Custom SQL Query"):
custom_query = st.text_area("Enter your SQL query:")
if st.button("Execute Query"):
if custom_query:
try:
db = SQLDatabase.from_uri(mysql_uri)
result = db.run(custom_query)
data = eval(result)
if data:
st.write("Query Result:")
try:
query_columns = f"""SHOW COLUMNS FROM ({custom_query}) AS tmp_table"""
columns_result = db.run(query_columns)
columns_list = eval(columns_result)
columns = [column[0] for column in columns_list]
st.dataframe(pd.DataFrame(data, columns=columns))
except:
st.dataframe(pd.DataFrame(data))
else:
st.write("Query returned no results.")
except Exception as e:
st.error(f"Error executing query: {e}")
else:
st.warning("Please enter a SQL query.")
Presentation GenerAItor
8 https://jalcocert.github.io/JAlcocerT/creating-presentations-with-ai/
Speech RAIter
AI is not only about text, but it can also be about AI generated audio.
Or interpreted audio.
CV CreAItor
- https://jalcocert.github.io/JAlcocerT/when-to-apply-for-a-job/
- https://jalcocert.github.io/JAlcocerT/scrap-and-chat-with-the-web
Have you ever thought that…
Diagram GenerAItor
For the ones in loved with Diagrams.
Youtube SummarAIzer
Because there is too much information (and noise) out there:
/blog_img/GenAI/yt-summaries/yt-summaries-groq_example.png
Youtube Script CreAItor
With Whisper
Conclusions
Many ideas…
If that was not enough…
How about adding a QR tool?
Like the one I used for this weddin.
Because the PIL package counts as AI, doesnt it?
Whats next?
Probably more NoCode stuff: https://www.youtube.com/@AI-GPTWorkshop/videos
The Market Test
Which of these very different use cases will be valued the most?
Product Analytics Tools
FAQ
Multichat
Books
- https://bookstash.io/ - Top books recommended by famous folk, in 3m or less.
Epub to AudioBook with Python: https://github.com/C-Loftus/QuickPiperAudiobook