Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ generate_files/*
generate_files_0/*
generated_file/*
generated_files/*
user_config_openai.key
user_config_openai.key
test_uploader.*
test_display_gxy.py
outputs_dir/*
outputs_smolagents_nicegui/*
!examples.json
__pycache__
.*key
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ groq_api_key.txt
*.pdf
generate_md_report.py
*.md
outputs/*
outputs/*
outputs_dir/
user_config_*
*.pkl
test*.py
test*.xml
226 changes: 26 additions & 200 deletions Chat.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ COPY . .
RUN pip install --no-cache-dir --upgrade pip

# Install Python dependencies from requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements_nicegui_dspy.txt

# Expose Streamlit’s port
EXPOSE 8501
ENV STREAMLIT_SERVER_PORT=8501
EXPOSE 9090

# Adjust permissions if needed
RUN chmod -R 777 /ChatAnalysis
63 changes: 27 additions & 36 deletions pages/1_Bookmarks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# pages/1_Bookmarks.py
import streamlit as st
import os
from PIL import Image # If displaying images from paths
from PIL import Image
import json


st.set_page_config(
Expand Down Expand Up @@ -69,13 +70,18 @@

st.title("🔖 Bookmark Manager")

# Ensure necessary session state variables are accessible
# These should have been set by Chat_Bot.py when it first ran.
output_dir = st.session_state.get("generate_file_path", "outputs_smolagents") # Default if not found
def load_chat_history():
if os.path.exists("bookmarks.json"):
with open("bookmarks.json", "r") as f:
file_contents = f.read().strip()
if file_contents:
history = json.loads(file_contents)
st.session_state["bookmarks"] = history.get("bookmarks", [])
else:
st.session_state["bookmarks"] = []

if "bookmarks" not in st.session_state:
st.session_state["bookmarks"] = [] # Initialize if somehow not present

load_chat_history()
bookmarks = st.session_state.get("bookmarks", [])

if not bookmarks:
Expand All @@ -93,36 +99,33 @@
file_paths = b_data.get("files", [])

with st.expander(f"Bookmark {i + 1}: {question[:60]}"):
st.markdown(f"**❓ Question:**\n```\n{question}\n```")
st.markdown(f"**💡 Answer:**\n{answer}") # Assuming answer is markdown-compatible
st.markdown(f"**❓ Question:**\n{question}\n")
st.markdown(f"**💡 Answer:**\n{answer}")

if plot_paths:
if plot_paths and not (len(plot_paths) == 1 and plot_paths[0] == ""):
st.markdown("**📊 Saved Plots:**")
for plot_path_in_bookmark in plot_paths:
# Construct full path if paths are stored relative or just basenames
# Assuming paths in bookmark_data are already correct relative to execution
# or are absolute. If relative to output_dir, prepend it.
# For simplicity, let's assume plot_path_in_bookmark is usable as is
# or is a full path. If it's just a basename:
# actual_plot_path = os.path.join(output_dir, os.path.basename(plot_path_in_bookmark))
actual_plot_path = plot_path_in_bookmark # Use this if paths are stored fully qualified or correctly relative

if os.path.exists(actual_plot_path):
actual_plot_path = plot_path_in_bookmark
if actual_plot_path == "":
continue

if actual_plot_path and os.path.exists(actual_plot_path):
try:
image = Image.open(actual_plot_path)
st.image(image, caption=os.path.basename(actual_plot_path))
except Exception as e:
st.error(f"Could not load plot {os.path.basename(actual_plot_path)}: {e}")
else:
st.warning(f"Plot not found: {actual_plot_path}")
pass

if file_paths:
if file_paths and not (len(file_paths) == 1 and file_paths[0] == ""):
st.markdown("**📄 Saved Files:**")
for file_path_in_bookmark in file_paths:
# actual_file_path = os.path.join(output_dir, os.path.basename(file_path_in_bookmark))
actual_file_path = file_path_in_bookmark # Similar assumption as plots
actual_file_path = file_path_in_bookmark
if actual_file_path == "":
continue

if os.path.exists(actual_file_path):
if actual_file_path and os.path.exists(actual_file_path):
try:
with open(actual_file_path, "rb") as f_download:
st.download_button(
Expand All @@ -134,16 +137,4 @@
except Exception as e:
st.error(f"Could not prepare file {os.path.basename(actual_file_path)} for download: {e}")
else:
st.warning(f"File not found: {actual_file_path}")

# Add delete/rerun functionality if desired (would need to modify st.session_state.bookmarks and save)
# e.g., if st.button("Delete Bookmark", key=f"delete_bm_{i}"):
# st.session_state.bookmarks.pop(i)
# # Need a way to trigger save_chat_history() from StreamlitApp if it's responsible,
# # or manage bookmark saving directly via session state + json persistence here.
# # For now, keep it simple.
# st.experimental_rerun()

# If you have common sidebar elements (like API config) that should appear on all pages,
# you might need to duplicate that logic here or move it to a shared utility function.
# For now, the Bookmarks page is simple and doesn't re-declare the LLM config sidebar.
pass
27 changes: 13 additions & 14 deletions tools/chat_analysis.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<tool id="interactive_tool_chat_analysis" tool_type="interactive" name="Chat with your data" version="0.2.2">
<tool id="interactive_tool_chat_analysis" tool_type="interactive" name="Chat with your data" version="0.3.0">
<icon src="datachat.png" />
<description>Use natural language to work with and analyze your data</description>
<requirements>
<container type="docker">
quay.io/goeckslab/chatanalysis:release
quay.io/goeckslab/chatanalysis:0.3.0
</container>
</requirements>
<entry_points>
<entry_point name="Chat with $input_dataset.element_identifier" requires_domain="True">
<port>
8501
9090
</port>
<url>
/
Expand All @@ -21,23 +21,22 @@
#import re
echo "Starting Streamlit" &&
echo "working dir now: `pwd`" &&
mkdir -p generated_files &&
mkdir -p outputs_dir &&
#set $sanitized_input_dataset = re.sub('[^\w\-_\.]', '_', $input_dataset.element_identifier.strip())
ln -sf '$input_dataset' "./${sanitized_input_dataset}";
echo "sanitized input dataset: $sanitized_input_dataset" &&
echo "input dataset: $input_dataset" &&
echo "$input_dataset.ext" &&
ln -sf $__tool_directory__/.env /ChatAnalysis/.env &&
streamlit run /ChatAnalysis/Chat.py
"$__user_email__"
"$openai_api_key_file"
"$groq_api_key_file"
"$chat_history"
"./generated_files"
"$input_dataset"
"$input_dataset.ext"
--browser.gatherUsageStats false &&
echo "Streamlit finished" &&
python /ChatAnalysis/chat_dspy.py
--user_id "$__user_email__"
--openai_key_file "$openai_api_key_file"
--groq_key_file "$groq_api_key_file"
--chat_history "$chat_history"
--outputs_dir "./outputs_dir"
--input_file "$input_dataset"
--input_type "$input_dataset.ext" &&
echo "finished" &&
echo "working dir now: '.' "

]]>
Expand Down
Loading