jcflash80 commited on
Commit
b9803ab
·
verified ·
1 Parent(s): 185940f

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -114
app.py DELETED
@@ -1,114 +0,0 @@
1
- import streamlit as st
2
- from claude import Claude
3
- from perplexity import Perplexity
4
- import pandas as pd
5
- import time
6
-
7
- st.set_page_config(page_title="AI Chat Interface", layout="wide")
8
-
9
- st.markdown("""
10
- <style>
11
- .uploadedFile {display: none}
12
- .stButton>button {
13
- width: 100%;
14
- }
15
- </style>""", unsafe_allow_html=True)
16
-
17
- def initialize_session_state():
18
- if "messages" not in st.session_state:
19
- st.session_state.messages = []
20
- if "claude" not in st.session_state:
21
- st.session_state.claude = Claude(api_key="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")
22
- if "perplexity" not in st.session_state:
23
- st.session_state.perplexity = Perplexity(api_key="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")
24
- if "df" not in st.session_state:
25
- st.session_state.df = None
26
-
27
- def process_integrated_analysis(perplexity_response, company_name, csv_data):
28
- csv_info = f"""CSV Data Summary:
29
- - Total Rows: {len(csv_data)}
30
- - Total Columns: {len(csv_data.columns)}
31
- - Columns: {', '.join(csv_data.columns)}
32
-
33
- Sample Data:
34
- {csv_data.head().to_string()}
35
-
36
- Data Types:
37
- {csv_data.dtypes.to_string()}"""
38
-
39
- claude_prompt = f"""Analyze this data combining the market research and CSV data:
40
-
41
- 1. Market Research about {company_name}:
42
- {perplexity_response}
43
-
44
- 2. CSV Data Information:
45
- {csv_info}
46
-
47
- Please provide:
48
- 1. Connections between the market research and CSV data
49
- 2. How the CSV data relates to {company_name}'s market position
50
- 3. Insights from combining both sources
51
- 4. Recommendations based on both the market research and data analysis"""
52
-
53
- return st.session_state.claude.generate_response(
54
- prompt=claude_prompt,
55
- system_prompt="You are a business analyst who specializes in combining market research with data analysis. Provide comprehensive insights that connect both sources of information."
56
- )
57
-
58
- def main():
59
- initialize_session_state()
60
-
61
- st.title("AI Chat Interface")
62
-
63
- col1, col2 = st.columns([1, 1])
64
-
65
- with col1:
66
- st.subheader("CSV File Analysis")
67
- uploaded_file = st.file_uploader("", type="csv", label_visibility="collapsed")
68
-
69
- if uploaded_file is not None:
70
- try:
71
- st.session_state.df = pd.read_csv(uploaded_file)
72
- st.success("CSV file loaded successfully!")
73
- st.write("Preview of your data:")
74
- st.dataframe(st.session_state.df.head(), use_container_width=True)
75
- except Exception as e:
76
- st.error(f"Error reading CSV file: {str(e)}")
77
-
78
- with col2:
79
- st.subheader("Search About the Company")
80
- user_prompt = st.text_area("Enter company name:", placeholder="Example: Nike, Apple, Tesla...")
81
-
82
- if st.button("Search"):
83
- if user_prompt and st.session_state.df is not None:
84
- try:
85
- with st.spinner("Gathering market research..."):
86
- perplexity_response = st.session_state.perplexity.analyze_company(user_prompt)
87
-
88
- with st.spinner("Performing integrated analysis..."):
89
- integrated_analysis = process_integrated_analysis(
90
- perplexity_response,
91
- user_prompt,
92
- st.session_state.df
93
- )
94
-
95
- st.session_state.messages.append({"role": "user", "content": f"Integrated Analysis for: {user_prompt}"})
96
- st.session_state.messages.append({"role": "perplexity", "content": perplexity_response})
97
- st.session_state.messages.append({"role": "claude", "content": integrated_analysis})
98
-
99
- st.text_area("Your Query:", user_prompt, height=100, disabled=True)
100
- col_a, col_b = st.columns(2)
101
- with col_a:
102
- st.text_area("Market Research (Perplexity):", perplexity_response, height=300, disabled=True)
103
- with col_b:
104
- st.text_area("Integrated Analysis (Claude):", integrated_analysis, height=300, disabled=True)
105
-
106
- except Exception as e:
107
- st.error(f"Error generating response: {str(e)}")
108
- else:
109
- if not user_prompt:
110
- st.warning("Please enter a company name")
111
- if st.session_state.df is None:
112
- st.warning("Please upload a CSV file first")
113
- if __name__ == "__main__":
114
- main()