返回 DeepSeek-Reasonix
endpoint.go
根目录 / internal / provider / anthropic / endpoint.go
1 package anthropic
2
3 import (
4 "strings"
5
6 "reasonix/internal/provider"
7 )
8
9 // resolveEndpoints returns the API root and the URL requests POST to. The root
10 // never carries a trailing /v1: users paste the OpenAI-style ".../v1" that
11 // /models probes expect, and appending /v1/messages to it would 404. A
12 // request_url that only repeats the root, with or without /v1, is unset.
13 func resolveEndpoints(baseURL string, extra map[string]any) (root, requestURL string) {
14 root = strings.TrimSuffix(strings.TrimRight(baseURL, "/"), "/v1")
15 if root == "" {
16 root = defaultBaseURL
17 }
18 requestURL, _ = extra["request_url"].(string)
19 requestURL = strings.TrimSpace(requestURL)
20 if requestURL == "" || provider.EndpointOverrideRepeatsBase(requestURL, root, root+"/v1") {
21 requestURL = root + "/v1/messages"
22 }
23 return root, requestURL
24 }
25
25 lines GO