Remove unused parameters
This commit is contained in:
parent
f62b104fbe
commit
ce8b08f725
5 changed files with 12 additions and 93 deletions
|
|
@ -35,7 +35,6 @@ type Provider struct {
|
|||
apiKey string
|
||||
apiBase string
|
||||
httpClient *http.Client
|
||||
lastResponseID string // tracks the previous response ID for multi-turn reasoning context
|
||||
}
|
||||
|
||||
// Option configures the Azure Provider.
|
||||
|
|
@ -107,11 +106,6 @@ func (p *Provider) Chat(
|
|||
requestBody.Instructions = openai.Opt(instructions)
|
||||
}
|
||||
|
||||
// Use previous_response_id for multi-turn reasoning context
|
||||
if p.lastResponseID != "" {
|
||||
requestBody.PreviousResponseID = openai.Opt(p.lastResponseID)
|
||||
}
|
||||
|
||||
if len(tools) > 0 {
|
||||
enableWebSearch, _ := options["native_search"].(bool)
|
||||
requestBody.Tools = orc.TranslateTools(tools, enableWebSearch)
|
||||
|
|
@ -157,7 +151,7 @@ func (p *Provider) Chat(
|
|||
return nil, common.HandleErrorResponse(resp, p.apiBase)
|
||||
}
|
||||
|
||||
return orc.ParseResponseBody(resp.Body, &p.lastResponseID)
|
||||
return orc.ParseResponseBody(resp.Body)
|
||||
}
|
||||
|
||||
// GetDefaultModel returns an empty string as Azure deployments are user-configured.
|
||||
|
|
|
|||
|
|
@ -247,54 +247,6 @@ func TestProviderChat_AzureParseToolCalls(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestProviderChat_AzurePreviousResponseID(t *testing.T) {
|
||||
var firstRequestBody, secondRequestBody map[string]any
|
||||
callCount := 0
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
callCount++
|
||||
var body map[string]any
|
||||
json.NewDecoder(r.Body).Decode(&body)
|
||||
if callCount == 1 {
|
||||
firstRequestBody = body
|
||||
} else {
|
||||
secondRequestBody = body
|
||||
}
|
||||
resp := map[string]any{
|
||||
"id": "resp_turn_1",
|
||||
"object": "response",
|
||||
"status": "completed",
|
||||
"output": []map[string]any{
|
||||
{"type": "message", "content": []map[string]any{
|
||||
{"type": "output_text", "text": "ok"},
|
||||
}},
|
||||
},
|
||||
"usage": map[string]any{
|
||||
"input_tokens": 5, "output_tokens": 2, "total_tokens": 7,
|
||||
"input_tokens_details": map[string]any{"cached_tokens": 0},
|
||||
"output_tokens_details": map[string]any{"reasoning_tokens": 0},
|
||||
},
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(resp)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
p := NewProvider("test-key", server.URL, "")
|
||||
|
||||
// First call — no previous_response_id
|
||||
_, _ = p.Chat(t.Context(), []Message{{Role: "user", Content: "hi"}}, nil, "deployment", nil)
|
||||
if firstRequestBody["previous_response_id"] != nil {
|
||||
t.Error("first call should not have previous_response_id")
|
||||
}
|
||||
|
||||
// Second call — should include previous_response_id from first response
|
||||
_, _ = p.Chat(t.Context(), []Message{{Role: "user", Content: "hello again"}}, nil, "deployment", nil)
|
||||
if secondRequestBody["previous_response_id"] != "resp_turn_1" {
|
||||
t.Errorf("previous_response_id = %v, want %q", secondRequestBody["previous_response_id"], "resp_turn_1")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvider_AzureEmptyAPIBase(t *testing.T) {
|
||||
p := NewProvider("test-key", "", "")
|
||||
_, err := p.Chat(t.Context(), []Message{{Role: "user", Content: "hi"}}, nil, "deployment", nil)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func (p *CodexProvider) Chat(
|
|||
}
|
||||
|
||||
// Respect tools.web.prefer_native: only inject native search when the agent
|
||||
// loop requested it (options["native_search"]), so prefer_native: false
|
||||
// loop passes options["native_search"]=true, so prefer_native=false means no injection.
|
||||
useNativeSearch := p.enableWebSearch && (options["native_search"] == true)
|
||||
params := buildCodexParams(messages, tools, resolvedModel, options, useNativeSearch)
|
||||
|
||||
|
|
|
|||
|
|
@ -214,17 +214,12 @@ func TranslateTools(tools []protocoltypes.ToolDefinition, enableWebSearch bool)
|
|||
|
||||
// ParseResponseBody parses an OpenAI Responses API JSON body into an LLMResponse.
|
||||
// Handles output item types: "message" (output_text + refusal), "function_call", and "reasoning".
|
||||
// If responseID is non-nil, stores the response ID for multi-turn context.
|
||||
func ParseResponseBody(body io.Reader, responseID *string) (*protocoltypes.LLMResponse, error) {
|
||||
func ParseResponseBody(body io.Reader) (*protocoltypes.LLMResponse, error) {
|
||||
var apiResp responses.Response
|
||||
if err := json.NewDecoder(body).Decode(&apiResp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if responseID != nil && apiResp.ID != "" {
|
||||
*responseID = apiResp.ID
|
||||
}
|
||||
|
||||
return parseResponse(&apiResp), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -317,8 +317,7 @@ func TestParseResponseBody_TextOutput(t *testing.T) {
|
|||
}
|
||||
}`)
|
||||
|
||||
var respID string
|
||||
result, err := ParseResponseBody(body, &respID)
|
||||
result, err := ParseResponseBody(body)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseResponseBody error: %v", err)
|
||||
}
|
||||
|
|
@ -328,9 +327,6 @@ func TestParseResponseBody_TextOutput(t *testing.T) {
|
|||
if result.FinishReason != "stop" {
|
||||
t.Errorf("FinishReason = %q, want %q", result.FinishReason, "stop")
|
||||
}
|
||||
if respID != "resp_123" {
|
||||
t.Errorf("responseID = %q, want %q", respID, "resp_123")
|
||||
}
|
||||
if result.Usage.TotalTokens != 15 {
|
||||
t.Errorf("TotalTokens = %d, want 15", result.Usage.TotalTokens)
|
||||
}
|
||||
|
|
@ -358,7 +354,7 @@ func TestParseResponseBody_FunctionCall(t *testing.T) {
|
|||
}
|
||||
}`)
|
||||
|
||||
result, err := ParseResponseBody(body, nil)
|
||||
result, err := ParseResponseBody(body)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseResponseBody error: %v", err)
|
||||
}
|
||||
|
|
@ -401,7 +397,7 @@ func TestParseResponseBody_Reasoning(t *testing.T) {
|
|||
}
|
||||
}`)
|
||||
|
||||
result, err := ParseResponseBody(body, nil)
|
||||
result, err := ParseResponseBody(body)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseResponseBody error: %v", err)
|
||||
}
|
||||
|
|
@ -433,7 +429,7 @@ func TestParseResponseBody_Refusal(t *testing.T) {
|
|||
}
|
||||
}`)
|
||||
|
||||
result, err := ParseResponseBody(body, nil)
|
||||
result, err := ParseResponseBody(body)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseResponseBody error: %v", err)
|
||||
}
|
||||
|
|
@ -458,7 +454,7 @@ func TestParseResponseBody_IncompleteStatus(t *testing.T) {
|
|||
"output_tokens_details": {"reasoning_tokens": 0}}
|
||||
}`)
|
||||
|
||||
result, err := ParseResponseBody(body, nil)
|
||||
result, err := ParseResponseBody(body)
|
||||
if err != nil {
|
||||
t.Fatalf("error: %v", err)
|
||||
}
|
||||
|
|
@ -478,7 +474,7 @@ func TestParseResponseBody_FailedStatus(t *testing.T) {
|
|||
"output_tokens_details": {"reasoning_tokens": 0}}
|
||||
}`)
|
||||
|
||||
result, err := ParseResponseBody(body, nil)
|
||||
result, err := ParseResponseBody(body)
|
||||
if err != nil {
|
||||
t.Fatalf("error: %v", err)
|
||||
}
|
||||
|
|
@ -488,24 +484,6 @@ func TestParseResponseBody_FailedStatus(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestParseResponseBody_NilResponseID(t *testing.T) {
|
||||
body := strings.NewReader(`{
|
||||
"id": "resp_nil",
|
||||
"object": "response",
|
||||
"status": "completed",
|
||||
"output": [],
|
||||
"usage": {"input_tokens": 0, "output_tokens": 0, "total_tokens": 0,
|
||||
"input_tokens_details": {"cached_tokens": 0},
|
||||
"output_tokens_details": {"reasoning_tokens": 0}}
|
||||
}`)
|
||||
|
||||
// Should not panic when responseID is nil
|
||||
_, err := ParseResponseBody(body, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// --- ParseDataAudioURL tests ---
|
||||
|
||||
func TestParseDataAudioURL_Valid(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue