Spaces:
Runtime error
Runtime error
Update ui/components.py
Browse files- ui/components.py +34 -11
ui/components.py
CHANGED
|
@@ -9,20 +9,23 @@ def create_sidebar():
|
|
| 9 |
st.title("🚀 Chart Analysis AI")
|
| 10 |
upload_option = st.radio(
|
| 11 |
"Choose input method:",
|
| 12 |
-
("Upload
|
| 13 |
key="sidebar_upload_method"
|
| 14 |
)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
if upload_option == "Upload
|
| 18 |
-
|
| 19 |
-
"Upload your
|
| 20 |
type=["png", "jpg", "jpeg"],
|
|
|
|
| 21 |
key="sidebar_file_uploader"
|
| 22 |
)
|
|
|
|
|
|
|
| 23 |
elif upload_option == "Take Screenshot":
|
| 24 |
if st.button("Take Screenshot", key="sidebar_screenshot_btn"):
|
| 25 |
-
st.info("Feature coming soon! For now, please use the Upload
|
| 26 |
|
| 27 |
st.subheader("Analysis Options")
|
| 28 |
patterns = st.multiselect(
|
|
@@ -36,15 +39,35 @@ def create_sidebar():
|
|
| 36 |
TECHNICAL_INDICATORS,
|
| 37 |
key="sidebar_indicators"
|
| 38 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
return upload_option,
|
| 41 |
|
| 42 |
-
def show_analysis_section(
|
| 43 |
"""Show the main analysis section"""
|
| 44 |
-
if
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
analyze_btn = st.button("Analyze
|
| 48 |
return analyze_btn
|
| 49 |
|
| 50 |
def show_chat_history(chat_history):
|
|
|
|
| 9 |
st.title("🚀 Chart Analysis AI")
|
| 10 |
upload_option = st.radio(
|
| 11 |
"Choose input method:",
|
| 12 |
+
("Upload Images", "Take Screenshot", "Ask Question"),
|
| 13 |
key="sidebar_upload_method"
|
| 14 |
)
|
| 15 |
|
| 16 |
+
uploaded_files = None
|
| 17 |
+
if upload_option == "Upload Images":
|
| 18 |
+
uploaded_files = st.file_uploader(
|
| 19 |
+
"Upload your charts",
|
| 20 |
type=["png", "jpg", "jpeg"],
|
| 21 |
+
accept_multiple_files=True, # Allow multiple files
|
| 22 |
key="sidebar_file_uploader"
|
| 23 |
)
|
| 24 |
+
if uploaded_files:
|
| 25 |
+
st.info(f"Uploaded {len(uploaded_files)} charts")
|
| 26 |
elif upload_option == "Take Screenshot":
|
| 27 |
if st.button("Take Screenshot", key="sidebar_screenshot_btn"):
|
| 28 |
+
st.info("Feature coming soon! For now, please use the Upload Images option.")
|
| 29 |
|
| 30 |
st.subheader("Analysis Options")
|
| 31 |
patterns = st.multiselect(
|
|
|
|
| 39 |
TECHNICAL_INDICATORS,
|
| 40 |
key="sidebar_indicators"
|
| 41 |
)
|
| 42 |
+
|
| 43 |
+
# Add comparison options
|
| 44 |
+
if uploaded_files and len(uploaded_files) > 1:
|
| 45 |
+
st.subheader("Comparison Options")
|
| 46 |
+
comparison_type = st.selectbox(
|
| 47 |
+
"Comparison Type",
|
| 48 |
+
["Individual Analysis", "Correlated Analysis", "Market Trend Analysis"],
|
| 49 |
+
key="comparison_type"
|
| 50 |
+
)
|
| 51 |
+
st.info("""
|
| 52 |
+
- Individual Analysis: Analyze each chart separately
|
| 53 |
+
- Correlated Analysis: Find relationships between charts
|
| 54 |
+
- Market Trend Analysis: Identify broader market patterns
|
| 55 |
+
""")
|
| 56 |
+
else:
|
| 57 |
+
comparison_type = "Individual Analysis"
|
| 58 |
|
| 59 |
+
return upload_option, uploaded_files, patterns, indicators, comparison_type
|
| 60 |
|
| 61 |
+
def show_analysis_section(uploaded_files):
|
| 62 |
"""Show the main analysis section"""
|
| 63 |
+
if uploaded_files:
|
| 64 |
+
# Create a grid layout for multiple images
|
| 65 |
+
cols = st.columns(min(len(uploaded_files), 2)) # Max 2 columns
|
| 66 |
+
for idx, uploaded_file in enumerate(uploaded_files):
|
| 67 |
+
with cols[idx % 2]:
|
| 68 |
+
st.image(uploaded_file, caption=f"Chart {idx + 1}", use_container_width=True)
|
| 69 |
|
| 70 |
+
analyze_btn = st.button("Analyze Charts", key="main_analyze_btn")
|
| 71 |
return analyze_btn
|
| 72 |
|
| 73 |
def show_chat_history(chat_history):
|