37-AN commited on
Commit
c7d6600
·
1 Parent(s): 03016b2

Initial commit for Hugging Face Space deployment

Browse files
app.py CHANGED
@@ -8,11 +8,17 @@ import os
8
  import sys
9
 
10
  # Make sure the app directory is in the path
 
11
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 
 
12
 
13
  # Create necessary directories
14
  os.makedirs('data/documents', exist_ok=True)
15
  os.makedirs('data/vector_db', exist_ok=True)
16
 
 
 
 
17
  # Run the Streamlit app with specific port to match huggingface-space.yml
18
  subprocess.run(["streamlit", "run", "app/ui/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"])
 
8
  import sys
9
 
10
  # Make sure the app directory is in the path
11
+ # Add the current directory to the path so that 'app' is recognized as a package
12
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
13
+ # Also add the parent directory to path to ensure imports work properly
14
+ sys.path.append(os.path.abspath('.'))
15
 
16
  # Create necessary directories
17
  os.makedirs('data/documents', exist_ok=True)
18
  os.makedirs('data/vector_db', exist_ok=True)
19
 
20
+ # Set environment variable for Python path
21
+ os.environ['PYTHONPATH'] = os.path.abspath('.')
22
+
23
  # Run the Streamlit app with specific port to match huggingface-space.yml
24
  subprocess.run(["streamlit", "run", "app/ui/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"])
app/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # This file marks 'app' as a Python package
app/core/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # This file marks 'app.core' as a Python package
app/ui/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # This file marks 'app.ui' as a Python package
app/ui/streamlit_app.py CHANGED
@@ -7,10 +7,20 @@ from typing import List, Dict, Any
7
 
8
  # Add project root to path for imports
9
  sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
10
- from app.core.agent import AssistantAgent
11
- from app.core.ingestion import DocumentProcessor
12
- from app.utils.helpers import get_document_path, format_sources, save_conversation
13
- from app.config import LLM_MODEL, EMBEDDING_MODEL
 
 
 
 
 
 
 
 
 
 
14
 
15
  # Set page config
16
  st.set_page_config(
 
7
 
8
  # Add project root to path for imports
9
  sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
10
+
11
+ # Use relative imports when running as part of the app package
12
+ try:
13
+ from app.core.agent import AssistantAgent
14
+ from app.core.ingestion import DocumentProcessor
15
+ from app.utils.helpers import get_document_path, format_sources, save_conversation
16
+ from app.config import LLM_MODEL, EMBEDDING_MODEL
17
+ except ImportError:
18
+ # Fallback to direct imports if app is not recognized as a package
19
+ sys.path.append(os.path.abspath('.'))
20
+ from app.core.agent import AssistantAgent
21
+ from app.core.ingestion import DocumentProcessor
22
+ from app.utils.helpers import get_document_path, format_sources, save_conversation
23
+ from app.config import LLM_MODEL, EMBEDDING_MODEL
24
 
25
  # Set page config
26
  st.set_page_config(
app/utils/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # This file marks 'app.utils' as a Python package