encryptd commited on
Commit
abba137
·
1 Parent(s): 511d3b2

prog update

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -5,6 +5,14 @@ import httpx
5
  import json
6
  import base64
7
  from io import BytesIO
 
 
 
 
 
 
 
 
8
  from fastapi import Request
9
  from fastapi.responses import StreamingResponse, JSONResponse
10
  import uvicorn
@@ -13,7 +21,7 @@ from openai import OpenAI
13
 
14
  # --- CONFIGURATION ---
15
  MODEL_ID = "numind/NuMarkdown-8B-Thinking"
16
- GPU_UTILIZATION = 0.85
17
  MAX_MODEL_LEN = 16384
18
  VLLM_PORT = 8000
19
  HF_PORT = 7860
@@ -87,10 +95,15 @@ with gr.Blocks(title="NuMarkdown API") as demo:
87
 
88
  # --- STEP 3: ATTACH PROXY TO GRADIO'S APP ---
89
  # We enable the queue for long tasks
 
 
90
  demo.queue()
91
 
92
  # We get the FastAPI instance from Gradio
93
  app = demo.app
 
 
 
94
 
95
  # We add the external API proxy directly to this app
96
  @app.api_route("/v1/{path:path}", methods=["GET", "POST", "PUT", "DELETE"])
 
5
  import json
6
  import base64
7
  from io import BytesIO
8
+
9
+ # Fix for Python 3.13 audioop removal
10
+ try:
11
+ import audioop
12
+ except ImportError:
13
+ import audioop_lts as audioop
14
+ sys.modules["audioop"] = audioop
15
+
16
  from fastapi import Request
17
  from fastapi.responses import StreamingResponse, JSONResponse
18
  import uvicorn
 
21
 
22
  # --- CONFIGURATION ---
23
  MODEL_ID = "numind/NuMarkdown-8B-Thinking"
24
+ GPU_UTILIZATION = 0.95
25
  MAX_MODEL_LEN = 16384
26
  VLLM_PORT = 8000
27
  HF_PORT = 7860
 
95
 
96
  # --- STEP 3: ATTACH PROXY TO GRADIO'S APP ---
97
  # We enable the queue for long tasks
98
+ # 1. FIX ATTRIBUTE ERROR: Patch missing attributes onto the demo object
99
+ demo.max_file_size = 100 * 1024 * 1024 # 100MB
100
  demo.queue()
101
 
102
  # We get the FastAPI instance from Gradio
103
  app = demo.app
104
+ # 3. Mount Gradio to FastAPI
105
+ # Using path="" and assigning to the app ensures assets are at the root
106
+ app = gr.mount_gradio_app(app, demo, path="/")
107
 
108
  # We add the external API proxy directly to this app
109
  @app.api_route("/v1/{path:path}", methods=["GET", "POST", "PUT", "DELETE"])