MCPcopy
hub / github.com/mudler/LocalAI / composeURL

Function composeURL

backend/go/cloud-proxy/proxy.go:397–406  ·  view source on GitHub ↗

composeURL combines the configured upstream URL with the per-request path. The upstream URL typically already includes the canonical path (e.g. https://api.openai.com/v1/chat/completions) so the per-request path is ignored in that case. When upstream_url is a bare host (https://api.openai.com), the

(upstream, reqPath string)

Source from the content-addressed store, hash-verified

395// path is ignored in that case. When upstream_url is a bare host
396// (https://api.openai.com), the request path is appended.
397func composeURL(upstream, reqPath string) (string, error) {
398 u, err := url.Parse(upstream)
399 if err != nil {
400 return "", fmt.Errorf("cloud-proxy: parse upstream_url %q: %w", upstream, err)
401 }
402 if u.Path == "" || u.Path == "/" {
403 u.Path = reqPath
404 }
405 return u.String(), nil
406}
407
408// applyAuthHeader writes the appropriate authorization header for the
409// provider. OpenAI/Anthropic/most providers use Bearer; Anthropic

Callers 2

ForwardMethod · 0.85

Calls 2

ParseMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected