Use PromptKit prepared execution for structured model calls

This commit is contained in:
2026-09-24 01:57:25 +00:00
parent 96d3d03bee
commit c8a78bf024
17 changed files with 560 additions and 1366 deletions

View File

@@ -2,29 +2,9 @@ package llm
import (
"fmt"
"net/http"
"reflect"
"strings"
"time"
)
func resolvedHTTPClient(base *http.Client, timeout time.Duration) *http.Client {
if base == nil {
if timeout <= 0 {
return http.DefaultClient
}
return &http.Client{Timeout: timeout}
}
if timeout <= 0 {
return base
}
cloned := *base
cloned.Timeout = timeout
return &cloned
}
func validateOutputTarget(out any) error {
if out == nil {
return fmt.Errorf("output target must not be nil")
@@ -35,16 +15,3 @@ func validateOutputTarget(out any) error {
}
return nil
}
func sanitizeError(err error, apiKey string) error {
if err == nil {
return nil
}
msg := err.Error()
key := strings.TrimSpace(apiKey)
if key != "" {
msg = strings.ReplaceAll(msg, key, "[REDACTED]")
msg = strings.ReplaceAll(msg, "Bearer "+key, "Bearer [REDACTED]")
}
return fmt.Errorf("%s", msg)
}