Spaces:
Runtime error
Runtime error
File size: 5,096 Bytes
5536b2b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | # import streamlit as st
# from PIL import Image
# import help
# st.set_page_config(page_title="Multimodal Chat", page_icon="🤖")
# st.title(" Multimodal Chat")
# # -------------------------
# # User Inputs
# # -------------------------
# text_input = st.text_area(
# "Enter your question (Optional)",
# placeholder="Ask something..."
# )
# uploaded_image = st.file_uploader(
# "Upload an image (Optional)",
# type=["png", "jpg", "jpeg"]
# )
# image = None
# if uploaded_image is not None:
# image = Image.open(uploaded_image)
# st.image(image, caption="Uploaded Image", width="stretch")
# # -------------------------
# # Submit Button
# # -------------------------
# if st.button("Submit"):
# # Check if at least one input is provided
# if not text_input and image is None:
# st.warning("Please provide either a text question or an image.")
# st.stop()
# # -------------------------
# # Case 1 : Text + Image
# # -------------------------
# if text_input and image is not None:
# st.success("Received both Text and Image")
# # Replace this with your model
# response = f"""
# Text:
# {text_input}
# Image received successfully.
# (Call your VLM here.)
# """
# # -------------------------
# # Case 2 : Only Text
# # -------------------------
# elif text_input:
# st.success("Received only Text")
# # Replace this with your LLM
# response = help.inital_step(text_input)
# # -------------------------
# # Case 3 : Only Image
# # -------------------------
# else:
# st.success("Received only Image")
# # Replace this with your Vision Model
# import tempfile
# if uploaded_image is not None:
# with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
# tmp.write(uploaded_image.getbuffer())
# temp_path = tmp.name
# response = help.image_input(temp_path)
# st.subheader("Response")
# st.write(response)
import streamlit as st
from PIL import Image
import tempfile
import help
st.set_page_config(page_title="Error Assistant", page_icon="🤖")
st.title("🤖 SQL / Excel Error Assistant")
# ----------------------------------------
# Select Task
# ----------------------------------------
task = st.selectbox(
"Choose Task",
[
"SQL Error",
"Excel Error"
]
)
# ----------------------------------------
# User Input
# ----------------------------------------
text_input = st.text_area(
"Enter your question (Optional)",
placeholder="Ask something..."
)
uploaded_image = st.file_uploader(
"Upload Screenshot (Optional)",
type=["png", "jpg", "jpeg"]
)
image = None
if uploaded_image:
image = Image.open(uploaded_image)
st.image(image, caption="Uploaded Image", width="stretch")
# ----------------------------------------
# Submit
# ----------------------------------------
if st.button("Submit"):
if not text_input and image is None:
st.warning("Please provide text or image.")
st.stop()
# ==========================
# SQL
# ==========================
if task == "SQL Error":
if text_input and image:
st.success("Received both Text and Image")
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
tmp.write(uploaded_image.getbuffer())
img_path = tmp.name
response = help.sql_text_image(text_input, img_path)
elif text_input:
st.success("Received only Text")
response = help.sql_text(text_input)
else:
st.success("Received only Image")
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
tmp.write(uploaded_image.getbuffer())
img_path = tmp.name
response = help.sql_image(img_path)
# ==========================
# Excel
# ==========================
else:
if text_input and image:
st.success("Received both Text and Image")
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
tmp.write(uploaded_image.getbuffer())
img_path = tmp.name
response = help.excel_text_image(text_input, img_path)
elif text_input:
st.success("Received only Text")
response = help.excel_text(text_input)
else:
st.success("Received only Image")
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
tmp.write(uploaded_image.getbuffer())
img_path = tmp.name
response = help.excel_image(img_path)
st.subheader("Response")
st.write(response) |