feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -103,7 +103,7 @@ func TestConvertOpenAIResponsesRequestToGeminiFunctionCallConversation(t *testin
|
||||
assert.Equal(t, map[string]any{"ok": true}, got.Contents[1].Parts[0].FunctionResponse.Response)
|
||||
}
|
||||
|
||||
func TestConvertOpenAIResponsesRequestToGeminiSkipsCustomToolCalls(t *testing.T) {
|
||||
func TestConvertOpenAIResponsesRequestToGeminiKeepsCustomToolCalls(t *testing.T) {
|
||||
got := mustConvertResponsesToGemini(t, dto.OpenAIResponsesRequest{
|
||||
Model: "gemini-test",
|
||||
Input: mustGeminiRawMessage(t, []map[string]any{
|
||||
@@ -140,17 +140,34 @@ func TestConvertOpenAIResponsesRequestToGeminiSkipsCustomToolCalls(t *testing.T)
|
||||
}),
|
||||
})
|
||||
|
||||
assert.Empty(t, got.GetTools())
|
||||
require.Len(t, got.Contents, 2)
|
||||
// The cleaned schema has no additionalProperties, and the unknown tool is dropped.
|
||||
assert.JSONEq(t, `[{"functionDeclarations":[{
|
||||
"name":"apply_patch",
|
||||
"description":"This tool takes freeform text. Put the complete raw text in the \"input\" argument.",
|
||||
"parameters":{"type":"OBJECT","properties":{"input":{"type":"STRING","description":"Raw input for the tool."}},"required":["input"]}
|
||||
}]}]`, string(got.Tools))
|
||||
|
||||
require.Len(t, got.Contents, 3)
|
||||
assert.Equal(t, "model", got.Contents[0].Role)
|
||||
require.Len(t, got.Contents[0].Parts, 1)
|
||||
assert.Equal(t, "before custom", got.Contents[0].Parts[0].Text)
|
||||
assert.Nil(t, got.Contents[0].Parts[0].FunctionCall)
|
||||
require.Len(t, got.Contents[0].Parts, 2)
|
||||
require.NotNil(t, got.Contents[0].Parts[0].FunctionCall)
|
||||
assert.Equal(t, "apply_patch", got.Contents[0].Parts[0].FunctionCall.FunctionName)
|
||||
assert.Equal(t, map[string]any{"input": "patch body"}, got.Contents[0].Parts[0].FunctionCall.Arguments)
|
||||
assert.Equal(t, "before custom", got.Contents[0].Parts[1].Text)
|
||||
|
||||
assert.Equal(t, "user", got.Contents[1].Role)
|
||||
require.Len(t, got.Contents[1].Parts, 1)
|
||||
assert.Equal(t, "next turn", got.Contents[1].Parts[0].Text)
|
||||
assert.Nil(t, got.Contents[1].Parts[0].FunctionResponse)
|
||||
require.Len(t, got.Contents[1].Parts, 2)
|
||||
for i, output := range []string{"ok", "legacy custom output"} {
|
||||
response := got.Contents[1].Parts[i].FunctionResponse
|
||||
require.NotNil(t, response)
|
||||
assert.Equal(t, "apply_patch", response.Name)
|
||||
assert.Equal(t, map[string]any{"content": output}, response.Response)
|
||||
assert.JSONEq(t, `"call_custom"`, string(response.ID))
|
||||
}
|
||||
|
||||
assert.Equal(t, "user", got.Contents[2].Role)
|
||||
require.Len(t, got.Contents[2].Parts, 1)
|
||||
assert.Equal(t, "next turn", got.Contents[2].Parts[0].Text)
|
||||
}
|
||||
|
||||
func mustConvertResponsesToGemini(t *testing.T, req dto.OpenAIResponsesRequest) *dto.GeminiChatRequest {
|
||||
|
||||
Reference in new issue
Block a user