gonalbz commited on
Commit
1379bdf
·
1 Parent(s): 62151d3
README.md CHANGED
@@ -4,7 +4,6 @@ colorFrom: blue
4
  colorTo: gray
5
  sdk: docker
6
  app_port: 7860
7
- base_path: /ui
8
  short_description: Transcript analysis API and Gradio interface.
9
  ---
10
 
@@ -92,7 +91,7 @@ http://127.0.0.1:8000/docs
92
  The Gradio frontend is available at:
93
 
94
  ```text
95
- http://127.0.0.1:8000/ui
96
  ```
97
 
98
  Analyze one transcript:
@@ -120,7 +119,7 @@ Analysis results are stored in memory, so they reset when the API process restar
120
 
121
  ## Hugging Face Spaces Deployment
122
 
123
- This repository is configured as a Docker Space. The container serves FastAPI and the mounted Gradio UI through Uvicorn on port `7860`, and the Space opens directly at `/ui`.
124
 
125
  Set `OPENAI_API_KEY` as a Hugging Face Space Secret. Optionally set `OPENAI_MODEL` as a Space Variable if you want to override the default model.
126
 
@@ -134,7 +133,7 @@ docker run --rm -p 7860:7860 --env-file .env aceup-transcript-analysis
134
  Then open:
135
 
136
  ```text
137
- http://127.0.0.1:7860/ui
138
  ```
139
 
140
  ## OpenAI Adapter Integration Test
 
4
  colorTo: gray
5
  sdk: docker
6
  app_port: 7860
 
7
  short_description: Transcript analysis API and Gradio interface.
8
  ---
9
 
 
91
  The Gradio frontend is available at:
92
 
93
  ```text
94
+ http://127.0.0.1:8000
95
  ```
96
 
97
  Analyze one transcript:
 
119
 
120
  ## Hugging Face Spaces Deployment
121
 
122
+ This repository is configured as a Docker Space. The container serves FastAPI and the mounted Gradio UI through Uvicorn on port `7860`. Hugging Face opens the Space at `/`, where the Gradio app is served directly.
123
 
124
  Set `OPENAI_API_KEY` as a Hugging Face Space Secret. Optionally set `OPENAI_MODEL` as a Space Variable if you want to override the default model.
125
 
 
133
  Then open:
134
 
135
  ```text
136
+ http://127.0.0.1:7860
137
  ```
138
 
139
  ## OpenAI Adapter Integration Test
app/main.py CHANGED
@@ -2,7 +2,7 @@ from functools import lru_cache
2
  from typing import Annotated
3
 
4
  from fastapi import Depends, FastAPI, Query, Request
5
- from fastapi.responses import JSONResponse, RedirectResponse
6
  import gradio as gr
7
 
8
  from app.adapters.openai import OpenAIAdapter
@@ -69,11 +69,6 @@ async def llm_completion_handler(_: Request, exc: LLMCompletionError) -> JSONRes
69
  return JSONResponse(status_code=502, content={"detail": str(exc)})
70
 
71
 
72
- @app.get("/", include_in_schema=False)
73
- def redirect_to_ui() -> RedirectResponse:
74
- return RedirectResponse(url="/ui")
75
-
76
-
77
  @app.get("/analyses", response_model=TranscriptAnalysisResponse)
78
  def analyze_transcript(
79
  transcript: Annotated[str, Query(description="Plain text transcript to analyze.")],
@@ -101,4 +96,4 @@ async def analyze_transcripts_batch(
101
  return to_batch_transcript_analysis_response(analyses)
102
 
103
 
104
- app = gr.mount_gradio_app(app, build_gradio_app(get_gradio_analysis_service), path="/ui")
 
2
  from typing import Annotated
3
 
4
  from fastapi import Depends, FastAPI, Query, Request
5
+ from fastapi.responses import JSONResponse
6
  import gradio as gr
7
 
8
  from app.adapters.openai import OpenAIAdapter
 
69
  return JSONResponse(status_code=502, content={"detail": str(exc)})
70
 
71
 
 
 
 
 
 
72
  @app.get("/analyses", response_model=TranscriptAnalysisResponse)
73
  def analyze_transcript(
74
  transcript: Annotated[str, Query(description="Plain text transcript to analyze.")],
 
96
  return to_batch_transcript_analysis_response(analyses)
97
 
98
 
99
+ app = gr.mount_gradio_app(app, build_gradio_app(get_gradio_analysis_service), path="/")
tests/api/test_transcript_analysis_api.py CHANGED
@@ -96,15 +96,8 @@ def test_analyze_batch_rejects_empty_transcript(client: TestClient) -> None:
96
  assert response.json()["detail"] == "Transcript cannot be empty."
97
 
98
 
99
- def test_gradio_ui_is_mounted(client: TestClient) -> None:
100
- response = client.get("/ui/", follow_redirects=True)
101
 
102
  assert response.status_code == 200
103
  assert "text/html" in response.headers["content-type"]
104
-
105
-
106
- def test_root_redirects_to_gradio_ui(client: TestClient) -> None:
107
- response = client.get("/", follow_redirects=False)
108
-
109
- assert response.status_code == 307
110
- assert response.headers["location"] == "/ui"
 
96
  assert response.json()["detail"] == "Transcript cannot be empty."
97
 
98
 
99
+ def test_gradio_ui_is_mounted_at_root(client: TestClient) -> None:
100
+ response = client.get("/", follow_redirects=True)
101
 
102
  assert response.status_code == 200
103
  assert "text/html" in response.headers["content-type"]