mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
feat(provider): per-model and per-path upstreams (#8)
Add modelBaseUrls and pathBaseUrls to openai-type providers.
This commit is contained in:
+16
-1
@@ -1291,7 +1291,22 @@ func (g *Gateway) handlePassthrough(w http.ResponseWriter, r *http.Request, u *u
|
||||
}
|
||||
}
|
||||
|
||||
upstreamURL := adapter.base() + "/" + rest
|
||||
upstreamBase := adapter.base()
|
||||
if oa, isOpenAI := adapter.(*openaiAdapter); isOpenAI && oa.hasUpstreamOverrides() {
|
||||
var model string
|
||||
if len(oa.modelBases) > 0 {
|
||||
m, hasModel, truncated, peekErr := peekPassthroughModel(r)
|
||||
if peekErr != nil {
|
||||
writeOAIError(w, http.StatusBadRequest, "invalid_request_error", "cannot read request body")
|
||||
return
|
||||
}
|
||||
if hasModel && !truncated {
|
||||
model = m
|
||||
}
|
||||
}
|
||||
upstreamBase = oa.passthroughBase(model, "/"+rest)
|
||||
}
|
||||
upstreamURL := upstreamBase + "/" + rest
|
||||
if r.URL.RawQuery != "" {
|
||||
upstreamURL += "?" + r.URL.RawQuery
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user