feat: align Go/Node DSML tool-call parsing drift tolerance and update API docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
CJACK
2026-05-10 16:17:46 +08:00
parent cee8757d14
commit eaeb403fda
32 changed files with 879 additions and 102 deletions

View File

@@ -0,0 +1,36 @@
package client
import (
"context"
"errors"
"net/http"
"testing"
"ds2api/internal/auth"
)
func TestCallCompletionDoesNotFallbackForNonIdempotentCompletion(t *testing.T) {
var fallbackCalled bool
client := &Client{
stream: doerFunc(func(*http.Request) (*http.Response, error) {
return nil, errors.New("ambiguous completion write failure")
}),
fallbackS: &http.Client{Transport: roundTripperFunc(func(*http.Request) (*http.Response, error) {
fallbackCalled = true
return &http.Response{StatusCode: http.StatusOK}, nil
})},
}
_, err := client.CallCompletion(
context.Background(),
&auth.RequestAuth{DeepSeekToken: "token"},
map[string]any{"prompt": "hello"},
"pow",
3,
)
if err == nil {
t.Fatal("expected completion error")
}
if fallbackCalled {
t.Fatal("completion fallback should not be called for a non-idempotent request")
}
}