aiqtech commited on
Commit
6511714
ยท
verified ยท
1 Parent(s): bbe1d5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -640,8 +640,10 @@ def create_gradio_interface(multi_agent_system: MultiAgentSystem, search_client:
640
  @asynccontextmanager
641
  async def lifespan(app: FastAPI):
642
  """์•ฑ ์ƒ๋ช…์ฃผ๊ธฐ ๊ด€๋ฆฌ"""
 
643
  print("\n" + "="*60)
644
  print("๐Ÿš€ Multi-Agent RAG System Starting...")
 
645
  print("="*60)
646
  yield
647
  print("\n๐Ÿ‘‹ Shutting down...")
@@ -679,12 +681,13 @@ except Exception as e:
679
  @app.get("/")
680
  async def root():
681
  """๋ฃจํŠธ ์—”๋“œํฌ์ธํŠธ"""
 
682
  return {
683
  "name": "Multi-Agent RAG System",
684
  "version": "3.0.0",
685
  "status": "running",
686
- "ui": "http://localhost:8000/ui",
687
- "docs": "http://localhost:8000/docs"
688
  }
689
 
690
 
@@ -776,17 +779,31 @@ if __name__ == "__main__":
776
  print("\n" + "="*60)
777
  print("โœ… ์‹œ์Šคํ…œ ์ค€๋น„ ์™„๋ฃŒ!")
778
  print("="*60)
779
- print("\n๐Ÿ“ ์ ‘์† ์ฃผ์†Œ:")
780
- print(" ๐ŸŽจ Gradio UI: http://localhost:8000/ui")
781
- print(" ๐Ÿ“š API Docs: http://localhost:8000/docs")
782
- print(" ๐Ÿ”ง Chat API: POST http://localhost:8000/api/chat")
 
 
 
 
 
 
 
 
 
 
783
  print("\n๐Ÿ’ก Ctrl+C๋ฅผ ๋ˆŒ๋Ÿฌ ์ข…๋ฃŒ")
784
  print("="*60 + "\n")
785
 
 
 
 
 
786
  uvicorn.run(
787
  app,
788
- host="0.0.0.0",
789
- port=8000,
790
  reload=False,
791
  log_level="info"
792
  )
 
640
  @asynccontextmanager
641
  async def lifespan(app: FastAPI):
642
  """์•ฑ ์ƒ๋ช…์ฃผ๊ธฐ ๊ด€๋ฆฌ"""
643
+ port = int(os.getenv("PORT", 7860))
644
  print("\n" + "="*60)
645
  print("๐Ÿš€ Multi-Agent RAG System Starting...")
646
+ print(f"๐Ÿ“ Port: {port}")
647
  print("="*60)
648
  yield
649
  print("\n๐Ÿ‘‹ Shutting down...")
 
681
  @app.get("/")
682
  async def root():
683
  """๋ฃจํŠธ ์—”๋“œํฌ์ธํŠธ"""
684
+ port = int(os.getenv("PORT", 7860))
685
  return {
686
  "name": "Multi-Agent RAG System",
687
  "version": "3.0.0",
688
  "status": "running",
689
+ "ui": f"http://localhost:{port}/ui",
690
+ "docs": f"http://localhost:{port}/docs"
691
  }
692
 
693
 
 
779
  print("\n" + "="*60)
780
  print("โœ… ์‹œ์Šคํ…œ ์ค€๋น„ ์™„๋ฃŒ!")
781
  print("="*60)
782
+
783
+ # Hugging Face Spaces ํ™˜๊ฒฝ ํ™•์ธ
784
+ is_hf_spaces = os.getenv("SPACE_ID") is not None
785
+ port = int(os.getenv("PORT", 7860))
786
+
787
+ if is_hf_spaces:
788
+ print("\n๐Ÿค— Hugging Face Spaces์—์„œ ์‹คํ–‰ ์ค‘...")
789
+ print(f" ํฌํŠธ: {port}")
790
+ else:
791
+ print("\n๐Ÿ“ ์ ‘์† ์ฃผ์†Œ:")
792
+ print(f" ๐ŸŽจ Gradio UI: http://localhost:{port}/ui")
793
+ print(f" ๐Ÿ“š API Docs: http://localhost:{port}/docs")
794
+ print(f" ๐Ÿ”ง Chat API: POST http://localhost:{port}/api/chat")
795
+
796
  print("\n๐Ÿ’ก Ctrl+C๋ฅผ ๋ˆŒ๋Ÿฌ ์ข…๋ฃŒ")
797
  print("="*60 + "\n")
798
 
799
+ # Hugging Face Spaces ํ™˜๊ฒฝ ๊ฐ์ง€
800
+ port = int(os.getenv("PORT", 7860))
801
+ host = "0.0.0.0"
802
+
803
  uvicorn.run(
804
  app,
805
+ host=host,
806
+ port=port,
807
  reload=False,
808
  log_level="info"
809
  )