mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-14 21:25:09 +08:00
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:
36
internal/deepseek/client/client_completion_test.go
Normal file
36
internal/deepseek/client/client_completion_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user