adi-123 commited on
Commit
91640d7
·
verified ·
1 Parent(s): d1299a1

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -87
app.py DELETED
@@ -1,87 +0,0 @@
1
- import streamlit as st
2
- from typing import List, IO
3
-
4
- # Import utilities you finalised
5
- from utils import (
6
- get_pdf_text,
7
- get_docx_text,
8
- get_text_chunks,
9
- get_vector_store,
10
- user_input,
11
- )
12
-
13
- # ---------------------------------------------------------------------------#
14
- # Main Streamlit application
15
- # ---------------------------------------------------------------------------#
16
- def main() -> None:
17
- # ----- Page configuration ------------------------------------------------
18
- st.set_page_config(
19
- page_title="Docosphere",
20
- page_icon="📄",
21
- layout="wide"
22
- )
23
-
24
- st.title("📄 Docosphere")
25
- st.markdown("*Where Documents Come Alive …*")
26
-
27
- # Two-column layout: Q&A on left, file upload on right
28
- col_left, col_right = st.columns([2, 1])
29
-
30
- # --------------------- Right column – document upload -------------------
31
- with col_right:
32
- st.markdown("### 📁 Document Upload")
33
- uploaded_files: List[IO[bytes]] = st.file_uploader(
34
- "Upload PDF or Word files",
35
- accept_multiple_files=True,
36
- type=["pdf", "docx"],
37
- help="You can select multiple files at once."
38
- )
39
-
40
- if st.button("🚀 Process Documents"):
41
- if not uploaded_files:
42
- st.warning("📋 Please upload at least one file first.")
43
- return
44
-
45
- with st.spinner("🔄 Extracting text & creating vector index…"):
46
- combined_text = ""
47
-
48
- pdfs = [f for f in uploaded_files if f.name.lower().endswith(".pdf")]
49
- docs = [f for f in uploaded_files if f.name.lower().endswith(".docx")]
50
-
51
- if pdfs:
52
- combined_text += get_pdf_text(pdfs)
53
- if docs:
54
- combined_text += get_docx_text(docs)
55
-
56
- if combined_text.strip():
57
- chunks = get_text_chunks(combined_text)
58
- get_vector_store(chunks)
59
- st.success("✅ Documents processed! Ask away in the left panel.")
60
- else:
61
- st.warning("⚠️ No readable text found in the uploaded files.")
62
-
63
- with st.expander("ℹ️ How to use"):
64
- st.markdown(
65
- """
66
- 1. Upload one or more **PDF** or **Word** documents.\n
67
- 2. Click **Process Documents** to build the knowledge index.\n
68
- 3. Ask natural-language questions in the input box (left column).\n
69
- 4. The assistant will either answer from its own model knowledge or
70
- retrieve context from your documents when needed.
71
- """
72
- )
73
-
74
- # ---------------------- Left column – chat interface --------------------
75
- with col_left:
76
- st.markdown("### 💬 Ask Your Question")
77
- question: str = st.text_input(
78
- "",
79
- placeholder="Type a question about your documents or general topics…"
80
- )
81
-
82
- if question:
83
- user_input(question)
84
-
85
- # Entry-point guard
86
- if __name__ == "__main__":
87
- main()