proxy: add support for anthropic v1/messages api (#417)

* proxy: add support for anthropic v1/messages api
* proxy: restrict loading message to /v1/chat/completions
This commit is contained in:
Benson Wong
2025-11-29 22:09:07 -08:00
committed by GitHub
parent a883d68d4f
commit c968da1b73
2 changed files with 17 additions and 12 deletions
+4 -1
View File
@@ -507,7 +507,10 @@ func (p *Process) ProxyRequest(w http.ResponseWriter, r *http.Request) {
// add a sync so the streaming client only runs when the goroutine has exited
isStreaming, _ := r.Context().Value(proxyCtxKey("streaming")).(bool)
if p.config.SendLoadingState != nil && *p.config.SendLoadingState && isStreaming {
// PR #417 (no support for anthropic v1/messages yet)
isChatCompletions := strings.HasPrefix(r.URL.Path, "/v1/chat/completions")
if p.config.SendLoadingState != nil && *p.config.SendLoadingState && isStreaming && isChatCompletions {
srw = newStatusResponseWriter(p, w)
go srw.statusUpdates(swapCtx)
} else {