Spaces:
Runtime error
Runtime error
Update pages/Omnieye.py
Browse files- pages/Omnieye.py +40 -9
pages/Omnieye.py
CHANGED
|
@@ -1,18 +1,49 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import re
|
|
|
|
|
|
|
| 3 |
|
| 4 |
st.title("👁️ Omnieye")
|
| 5 |
-
st.write("Keyword/file analyzer module")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
uploaded = st.file_uploader("Upload a text/log file", type=["txt", "log"])
|
| 8 |
if uploaded:
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import re
|
| 3 |
+
from utils.file_utils import keyword_search
|
| 4 |
+
from utils.summarizer import summarize_text
|
| 5 |
|
| 6 |
st.title("👁️ Omnieye")
|
| 7 |
+
st.write("Keyword/file analyzer module with AI summarization")
|
| 8 |
+
|
| 9 |
+
# Initialize counters if not set
|
| 10 |
+
if "uploaded_files" not in st.session_state:
|
| 11 |
+
st.session_state.uploaded_files = []
|
| 12 |
+
if "errors" not in st.session_state:
|
| 13 |
+
st.session_state.errors = []
|
| 14 |
|
| 15 |
uploaded = st.file_uploader("Upload a text/log file", type=["txt", "log"])
|
| 16 |
if uploaded:
|
| 17 |
+
try:
|
| 18 |
+
content = uploaded.read().decode("utf-8", errors="ignore")
|
| 19 |
+
|
| 20 |
+
# Track uploaded file
|
| 21 |
+
st.session_state.uploaded_files.append(uploaded.name)
|
| 22 |
+
|
| 23 |
+
# Keyword search
|
| 24 |
+
query = st.text_input("🔍 Search for keyword")
|
| 25 |
+
matches = []
|
| 26 |
+
if query:
|
| 27 |
+
matches = keyword_search(content, query)
|
| 28 |
+
st.write(f"Found {len(matches)} matches")
|
| 29 |
+
st.code("\n".join(matches[:50]))
|
| 30 |
+
|
| 31 |
+
# File preview
|
| 32 |
+
st.subheader("📋 File Preview")
|
| 33 |
+
st.code("\n".join(content.splitlines()[:30]))
|
| 34 |
+
|
| 35 |
+
# AI Summarization
|
| 36 |
+
st.subheader("🧠 AI Summary")
|
| 37 |
+
summary = summarize_text(content)
|
| 38 |
+
st.write(summary)
|
| 39 |
|
| 40 |
+
# Save results to session state (for Chatbot context)
|
| 41 |
+
st.session_state.omnieye_output = {
|
| 42 |
+
"file_preview": "\n".join(content.splitlines()[:30]),
|
| 43 |
+
"matches": matches[:50],
|
| 44 |
+
"summary": summary,
|
| 45 |
+
}
|
| 46 |
|
| 47 |
+
except Exception as e:
|
| 48 |
+
st.error(f"⚠️ Error processing file: {e}")
|
| 49 |
+
st.session_state.errors.append(str(e))
|