Files
FuDie0915 db73cf5a39 chore: import Local-Cursor v1.1.8 source snapshot
Includes the current working directory changes. Historical commits and release binaries are excluded to limit Gitea storage.
Source base: d7515973fbfd6dd2001fa156c483455b8081c7cb
2026-11-10 01:24:28 +08:00

50 lines
1.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// retry.go 保留 provider HTTP 请求入口的历史命名;provider 错误交给客户端重连链路处理。
package modeladapter
import (
"context"
"net/http"
)
// DoProviderRequestWithRetry 保留旧入口名;本地模式不在服务端重试 provider 请求。
func DoProviderRequestWithRetry(
ctx context.Context,
client *http.Client,
provider string,
requestID string,
modelCallID string,
buildRequest func(context.Context) (*http.Request, error),
) (*http.Response, error) {
return doProviderRequestWithRetry(ctx, client, provider, requestID, modelCallID, buildRequest)
}
func doProviderRequestWithRetry(
ctx context.Context,
client *http.Client,
provider string,
requestID string,
modelCallID string,
buildRequest func(context.Context) (*http.Request, error),
) (*http.Response, error) {
if client == nil {
client = http.DefaultClient
}
httpReq, err := buildRequest(ctx)
if err != nil {
return nil, err
}
resp, err := client.Do(httpReq)
if err != nil {
if resp != nil && resp.Body != nil {
_ = resp.Body.Close()
}
return nil, err
}
return resp, nil
}
// ProviderRetryAttemptSummary 返回空值;provider 请求不再有服务端内部重试摘要。
func ProviderRetryAttemptSummary(resp *http.Response) string {
return ""
}