richard-su commited on
Commit
60b9fce
Β·
verified Β·
1 Parent(s): 6640fdd

Upload folder using huggingface_hub

Browse files
src/__pycache__/app.cpython-310.pyc CHANGED
Binary files a/src/__pycache__/app.cpython-310.pyc and b/src/__pycache__/app.cpython-310.pyc differ
 
src/app.py CHANGED
@@ -24,7 +24,7 @@ except ImportError:
24
  # ==================== Application Creation Function ====================
25
 
26
  def create_app():
27
- """Create and return complete Gradio + MCP application"""
28
 
29
  print("πŸš€ Starting Gradio + FastMCP server")
30
 
@@ -68,7 +68,20 @@ def create_app():
68
  ):
69
  return await mcp_tools.read_text_file_segments(file_path, chunk_size, start_position)
70
 
71
- # Create FastAPI wrapper
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  fastapi_wrapper = FastAPI(
73
  title="Modal AudioTranscriber MCP",
74
  description="Gradio UI + FastMCP Tool + Modal Integration AudioTranscriber MCP",
@@ -82,14 +95,11 @@ def create_app():
82
  # Mount FastMCP application to /api path
83
  fastapi_wrapper.mount("/api", mcp_app)
84
 
85
- # Create Gradio interface
86
- ui_app = create_gradio_interface()
87
-
88
  # Use Gradio's standard mounting approach
89
  final_app = mount_gradio_app(
90
  app=fastapi_wrapper,
91
- blocks=ui_app,
92
- path="/",
93
  app_kwargs={
94
  "docs_url": "/docs",
95
  "redoc_url": "/redoc",
@@ -142,12 +152,23 @@ def run_local():
142
 
143
  print(f"🌐 Starting server on port {port}")
144
 
145
- uvicorn.run(
146
- app,
147
- host="0.0.0.0",
148
- port=port,
149
- reload=False
150
- )
 
 
 
 
 
 
 
 
 
 
 
151
 
152
  if __name__ == "__main__":
153
  run_local()
 
24
  # ==================== Application Creation Function ====================
25
 
26
  def create_app():
27
+ """Create and return Gradio application with MCP tools integrated"""
28
 
29
  print("πŸš€ Starting Gradio + FastMCP server")
30
 
 
68
  ):
69
  return await mcp_tools.read_text_file_segments(file_path, chunk_size, start_position)
70
 
71
+ # Create Gradio interface
72
+ print("🎨 Creating Gradio interface...")
73
+ gradio_app = create_gradio_interface()
74
+
75
+ # For HF Spaces, return Gradio app directly
76
+ if os.environ.get("HF_SPACES_MODE") == "1":
77
+ print("πŸ€— HF Spaces mode: returning Gradio app directly")
78
+ print("βœ… Server startup completed")
79
+ print("🎨 Gradio UI: /")
80
+ print(f"πŸ“ Server name: {mcp.name}")
81
+ return gradio_app
82
+
83
+ # For other environments, create FastAPI wrapper with MCP
84
+ print("πŸ”§ Creating FastAPI wrapper...")
85
  fastapi_wrapper = FastAPI(
86
  title="Modal AudioTranscriber MCP",
87
  description="Gradio UI + FastMCP Tool + Modal Integration AudioTranscriber MCP",
 
95
  # Mount FastMCP application to /api path
96
  fastapi_wrapper.mount("/api", mcp_app)
97
 
 
 
 
98
  # Use Gradio's standard mounting approach
99
  final_app = mount_gradio_app(
100
  app=fastapi_wrapper,
101
+ blocks=gradio_app,
102
+ path="",
103
  app_kwargs={
104
  "docs_url": "/docs",
105
  "redoc_url": "/redoc",
 
152
 
153
  print(f"🌐 Starting server on port {port}")
154
 
155
+ # For HF Spaces with Gradio app, launch directly
156
+ if os.environ.get("HF_SPACES_MODE") == "1" and hasattr(app, 'launch'):
157
+ print("πŸ€— Launching Gradio app for HF Spaces")
158
+ app.launch(
159
+ server_name="0.0.0.0",
160
+ server_port=port,
161
+ share=False,
162
+ show_error=True
163
+ )
164
+ else:
165
+ # For other environments, use uvicorn
166
+ uvicorn.run(
167
+ app,
168
+ host="0.0.0.0",
169
+ port=port,
170
+ reload=False
171
+ )
172
 
173
  if __name__ == "__main__":
174
  run_local()
src/ui/__pycache__/gradio_ui.cpython-310.pyc CHANGED
Binary files a/src/ui/__pycache__/gradio_ui.cpython-310.pyc and b/src/ui/__pycache__/gradio_ui.cpython-310.pyc differ
 
src/ui/gradio_ui.py CHANGED
@@ -10,6 +10,29 @@ from ..tools.download_tools import get_file_info_tool, get_mp3_files_tool, read_
10
  from ..tools.transcription_tools import transcribe_audio_file_tool
11
  import os
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  def create_gradio_interface():
14
  """Create Gradio interface
15
 
 
10
  from ..tools.transcription_tools import transcribe_audio_file_tool
11
  import os
12
 
13
+ def write_text_file_content(file_path: str, content: str, mode: str = "w", position: int = None):
14
+ """Simple text file writing function"""
15
+ try:
16
+ if mode == "r+" and position is not None:
17
+ with open(file_path, mode, encoding='utf-8') as f:
18
+ f.seek(position)
19
+ characters_written = f.write(content)
20
+ else:
21
+ with open(file_path, mode, encoding='utf-8') as f:
22
+ characters_written = f.write(content)
23
+
24
+ return {
25
+ "status": "success",
26
+ "characters_written": characters_written,
27
+ "operation_type": mode,
28
+ "size_change": len(content)
29
+ }
30
+ except Exception as e:
31
+ return {
32
+ "status": "failed",
33
+ "error_message": str(e)
34
+ }
35
+
36
  def create_gradio_interface():
37
  """Create Gradio interface
38