mozzic commited on
Commit
df23613
·
verified ·
1 Parent(s): 0bc3c4d

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +23 -19
app.py CHANGED
@@ -1,27 +1,31 @@
1
  #!/usr/bin/env python3
2
- """
3
- Hugging Face Spaces entry point for Context Thread Agent
4
- """
5
-
6
  import os
7
  import sys
8
  from pathlib import Path
9
 
10
- # Add current directory and src to path for imports
11
- current_dir = Path(__file__).parent
12
- sys.path.insert(0, str(current_dir / "ui"))
13
- sys.path.insert(0, str(current_dir / "src"))
14
 
15
- # Import and run the Gradio app
16
- from ui.app import create_gradio_app
 
17
 
18
- if __name__ == "__main__":
19
- # Create and launch the app
20
- demo = create_gradio_app()
21
 
22
- # Launch for HF Spaces (they handle port and host)
23
- demo.launch(
24
- server_name="0.0.0.0",
25
- server_port=int(os.environ.get("PORT", 7860)),
26
- show_error=True
27
- )
 
 
 
 
 
 
 
 
1
  #!/usr/bin/env python3
2
+ """Hugging Face Spaces entry point"""
 
 
 
3
  import os
4
  import sys
5
  from pathlib import Path
6
 
7
+ # Get the app directory
8
+ app_dir = Path(__file__).parent
9
+ os.chdir(app_dir)
 
10
 
11
+ # Add to path
12
+ if str(app_dir) not in sys.path:
13
+ sys.path.insert(0, str(app_dir))
14
 
15
+ # Now try the import
16
+ try:
17
+ from ui.app import create_gradio_app
18
 
19
+ if __name__ == "__main__":
20
+ demo = create_gradio_app()
21
+ demo.launch(
22
+ server_name="0.0.0.0",
23
+ server_port=int(os.environ.get("PORT", 7860)),
24
+ show_error=True
25
+ )
26
+ except ImportError as e:
27
+ print(f"Import error: {e}")
28
+ print(f"Current directory: {os.getcwd()}")
29
+ print(f"Python path: {sys.path}")
30
+ print(f"Files in current dir: {list(app_dir.iterdir())}")
31
+ raise