import streamlit as st from utils import query_agent # Basic UI st.title("CSV Analyst with Claude") st.header("Upload your CSV file for analysis") # Input Anthropic API key anthropic_api_key = st.text_input("Enter your Anthropic API Key:", type="password") # Capture the CSV file data = st.file_uploader("Upload CSV file", type="csv") query = st.text_area("What would you like to know about your data?") # Check if Anthropic API key is available if anthropic_api_key: # If Anthropic API key is available, show submit button button = st.button("Analyze") if button and data is not None: try: with st.spinner("Claude is analyzing your data..."): # Get Response answer = query_agent(data, query, api_key=anthropic_api_key) st.write(answer) except Exception as e: st.error(f"An error occurred: {str(e)}") elif button and data is None: st.warning("Please upload a CSV file first.") else: st.warning("Please input your Anthropic API key to continue.")