Spaces:
Sleeping
Sleeping
Arif
commited on
Commit
Β·
ca37c17
1
Parent(s):
e3d2b77
Updated app.py v11
Browse files
app.py
CHANGED
|
@@ -12,10 +12,9 @@ st.set_page_config(
|
|
| 12 |
st.title("π LLM Data Analyzer")
|
| 13 |
st.write("*Analyze data and chat with AI - Powered by Hugging Face Spaces*")
|
| 14 |
|
| 15 |
-
# Simple AI responses without API calls
|
| 16 |
def get_ai_response(prompt):
|
| 17 |
"""Generate simple AI-like responses without external API"""
|
| 18 |
-
# Since HF APIs require auth, we'll use simple pattern matching
|
| 19 |
prompt_lower = prompt.lower()
|
| 20 |
|
| 21 |
# Data analysis responses
|
|
@@ -91,10 +90,9 @@ with tab1:
|
|
| 91 |
)
|
| 92 |
|
| 93 |
if question:
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
st.write(response)
|
| 98 |
|
| 99 |
except Exception as e:
|
| 100 |
st.error(f"Error reading file: {e}")
|
|
@@ -123,21 +121,22 @@ with tab2:
|
|
| 123 |
)
|
| 124 |
|
| 125 |
if user_input:
|
| 126 |
-
# Add user message
|
| 127 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 128 |
|
| 129 |
-
#
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
| 141 |
|
| 142 |
# ============================================================================
|
| 143 |
# TAB 3: About
|
|
|
|
| 12 |
st.title("π LLM Data Analyzer")
|
| 13 |
st.write("*Analyze data and chat with AI - Powered by Hugging Face Spaces*")
|
| 14 |
|
| 15 |
+
# Simple AI responses without API calls
|
| 16 |
def get_ai_response(prompt):
|
| 17 |
"""Generate simple AI-like responses without external API"""
|
|
|
|
| 18 |
prompt_lower = prompt.lower()
|
| 19 |
|
| 20 |
# Data analysis responses
|
|
|
|
| 90 |
)
|
| 91 |
|
| 92 |
if question:
|
| 93 |
+
response = get_ai_response(question)
|
| 94 |
+
st.success("β
Analysis Complete")
|
| 95 |
+
st.write(response)
|
|
|
|
| 96 |
|
| 97 |
except Exception as e:
|
| 98 |
st.error(f"Error reading file: {e}")
|
|
|
|
| 121 |
)
|
| 122 |
|
| 123 |
if user_input:
|
| 124 |
+
# Add user message immediately
|
| 125 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 126 |
|
| 127 |
+
# Get response
|
| 128 |
+
response = get_ai_response(user_input)
|
| 129 |
+
|
| 130 |
+
# Add assistant message
|
| 131 |
+
st.session_state.messages.append({
|
| 132 |
+
"role": "assistant",
|
| 133 |
+
"content": response
|
| 134 |
+
})
|
| 135 |
+
|
| 136 |
+
# Display latest messages
|
| 137 |
+
st.divider()
|
| 138 |
+
with st.chat_message("assistant"):
|
| 139 |
+
st.markdown(response)
|
| 140 |
|
| 141 |
# ============================================================================
|
| 142 |
# TAB 3: About
|