feat(llm): 连接测试打印网关原始响应(状态码+响应体)
点击后台「测试」时,把每次 HTTP 尝试的状态码与原始 wire body 打进
服务端日志,便于诊断 401/额度文案/空帧/返回 HTML 页面等情况——不再
只看到 UI 折叠后的 ok/err。
- llmrec.Capture 新增 Attempts(),按次返回 {状态码, 响应体}
- TestConnection 自建 Capture 挂到 ctx(不依赖 LLM 记录开关),
经 quotaAwareTransport 填充后由 logTestConnection 输出,body 裁到 4K
This commit is contained in:
1 parent
a2f7ac9747
commit
3ddb0cb808
2 files changed
+60
No files matched your search
@@ -119,6 +119,28 @@ func (c *Capture) RawResponse() string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Attempt is one HTTP round trip's status code and response bytes.
|
||||
type Attempt struct {
|
||||
Status int
|
||||
Body string
|
||||
}
|
||||
|
||||
// Attempts returns every round trip in order. Unlike RawResponse — which drops
|
||||
// the header line for a lone attempt so the bytes stay replayable — this always
|
||||
// carries the status code, for callers that must report "HTTP 401 + body".
|
||||
func (c *Capture) Attempts() []Attempt {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
out := make([]Attempt, 0, len(c.attempts))
|
||||
for _, a := range c.attempts {
|
||||
out = append(out, Attempt{Status: a.status, Body: a.body.String()})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// teeBody mirrors reads into a Capture attempt, guarded by the Capture's mutex
|
||||
// so a snapshot taken mid-stream never races the writer.
|
||||
type teeBody struct {
|
||||
|
||||
Reference in new issue
Block a user