mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-03 06:52:13 +08:00
Propagate UpstreamModel through ForwardResult and OpenAIForwardResult in Anthropic direct, API-key passthrough, Bedrock, and OpenAI gateway flows. Extract optionalNonEqualStringPtr and optionalTrimmedStringPtr into usage_log_helpers.go. Store upstream_model only when it differs from the requested model. Also introduces anthropicPassthroughForwardInput struct to reduce parameter count.
22 lines
511 B
Go
22 lines
511 B
Go
package service
|
|
|
|
import "strings"
|
|
|
|
func optionalTrimmedStringPtr(raw string) *string {
|
|
trimmed := strings.TrimSpace(raw)
|
|
if trimmed == "" {
|
|
return nil
|
|
}
|
|
return &trimmed
|
|
}
|
|
|
|
// optionalNonEqualStringPtr returns a pointer to value if it is non-empty and
|
|
// differs from compare; otherwise nil. Used to store upstream_model only when
|
|
// it differs from the requested model.
|
|
func optionalNonEqualStringPtr(value, compare string) *string {
|
|
if value == "" || value == compare {
|
|
return nil
|
|
}
|
|
return &value
|
|
}
|