Skip to content

Commit 798da36

Browse files
committed
fix: update agent streaming configuration to include speech-response endpoint
1 parent 563d03a commit 798da36

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

  • adminforth/documentation/docs/tutorial/08-Plugins

adminforth/documentation/docs/tutorial/08-Plugins/01-agent.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,9 @@ If your existing checkpoint table already uses different column names, keep your
700700

701701
## Reverse proxy and CDN configuration for streaming
702702

703-
The agent streams responses from `<baseURL>/adminapi/v1/agent/response` using server-sent events, where `<baseURL>` is your AdminForth base path or an empty string when deployed at the domain root. If your proxy buffers responses, the UI will receive the answer only after generation is finished.
703+
The agent streams responses from `<baseURL>/adminapi/v1/agent/response` using server-sent events, where `<baseURL>` is your AdminForth base path or an empty string when deployed at the domain root. Voice mode also streams from `<baseURL>/adminapi/v1/agent/speech-response` after uploading the recorded audio. If your proxy buffers responses, the UI will receive the answer only after generation is finished.
704704

705-
For Nginx, disable response buffering on this endpoint. The critical line is `proxy_buffering off;`.
705+
For Nginx, disable response buffering on both endpoints. The critical line is `proxy_buffering off;`.
706706

707707
```nginx
708708
location <baseURL>/adminapi/v1/agent/response {
@@ -714,9 +714,19 @@ location <baseURL>/adminapi/v1/agent/response {
714714
proxy_buffering off; # required for streaming
715715
proxy_pass http://127.0.0.1:3500;
716716
}
717+
718+
location <baseURL>/adminapi/v1/agent/speech-response {
719+
proxy_http_version 1.1;
720+
proxy_read_timeout 600s;
721+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
722+
proxy_set_header Host $http_host;
723+
proxy_set_header Connection "";
724+
proxy_buffering off; # required for streaming voice responses
725+
proxy_pass http://127.0.0.1:3500;
726+
}
717727
```
718728

719-
Traefik forwards streaming responses immediately by default. The line that must stay off this route is any buffering middleware attachment such as `traefik.http.routers.adminforth-agent.middlewares=buffering@docker`. If your main router uses extra middlewares, create a dedicated router for the agent stream endpoint and do not attach buffering to it:
729+
Traefik forwards streaming responses immediately by default. The line that must stay off these routes is any buffering middleware attachment such as `traefik.http.routers.adminforth-agent.middlewares=buffering@docker`. If your main router uses extra middlewares, create a dedicated router for the agent stream endpoints and do not attach buffering to it:
720730

721731
```yaml title='./compose.yml'
722732
services:
@@ -730,7 +740,7 @@ services:
730740
- "traefik.http.routers.adminforth.tls.certresolver=myresolver"
731741
- "traefik.http.routers.adminforth.middlewares=secure-headers,buffering@docker"
732742

733-
- "traefik.http.routers.adminforth-agent.rule=Path(`<baseURL>/adminapi/v1/agent/response`)"
743+
- "traefik.http.routers.adminforth-agent.rule=Path(`<baseURL>/adminapi/v1/agent/response`) || Path(`<baseURL>/adminapi/v1/agent/speech-response`)"
734744
- "traefik.http.routers.adminforth-agent.priority=100"
735745
- "traefik.http.routers.adminforth-agent.service=adminforth"
736746
- "traefik.http.routers.adminforth-agent.tls=true"
@@ -740,12 +750,13 @@ services:
740750
# - "traefik.http.routers.adminforth-agent.middlewares=buffering@docker"
741751
```
742752

743-
Replace `<baseURL>` with the same base path you use for AdminForth. For example, when `ADMIN_BASE_URL = '/admin/'`, the endpoint becomes `/admin/adminapi/v1/agent/response`.
753+
Replace `<baseURL>` with the same base path you use for AdminForth. For example, when `ADMIN_BASE_URL = '/admin/'`, the endpoints become `/admin/adminapi/v1/agent/response` and `/admin/adminapi/v1/agent/speech-response`.
744754

745755
### CDN
746756

747-
Cloudflare by default buffers responses, which breaks streaming. To fix it, create a page rule for your domain with a "Response Body Buffering" setting turned off for the agent stream endpoint (`<baseURL>/adminapi/v1/agent/response`).
757+
Cloudflare by default buffers responses, which breaks streaming. To fix it, create a page rule for your domain with a "Response Body Buffering" setting turned off for the agent stream endpoints (`<baseURL>/adminapi/v1/agent/response` and `<baseURL>/adminapi/v1/agent/speech-response`).
748758

749-
![alt text](image-6.png)
759+
If Cloudflare returns a 403 response with `cf-mitigated: challenge` for `<baseURL>/adminapi/v1/agent/speech-response`, the request was blocked before it reached AdminForth. Create a WAF or bot rule exception for authenticated requests to this endpoint, because browser `fetch` calls with `multipart/form-data` cannot complete an HTML challenge page.
750760

761+
![alt text](image-6.png)
751762

0 commit comments

Comments
 (0)