mirror of
https://github.com/githubhjs/CLIProxyAPIPlus.git
synced 2026-07-12 01:25:13 +00:00
Merge branch 'router-for-me:main' into main
This commit is contained in:
@@ -211,6 +211,8 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
||||||
tool, _ = sjson.Delete(tool, "strict")
|
tool, _ = sjson.Delete(tool, "strict")
|
||||||
tool, _ = sjson.Delete(tool, "input_examples")
|
tool, _ = sjson.Delete(tool, "input_examples")
|
||||||
|
tool, _ = sjson.Delete(tool, "type")
|
||||||
|
tool, _ = sjson.Delete(tool, "cache_control")
|
||||||
toolsJSON, _ = sjson.SetRaw(toolsJSON, "0.functionDeclarations.-1", tool)
|
toolsJSON, _ = sjson.SetRaw(toolsJSON, "0.functionDeclarations.-1", tool)
|
||||||
toolDeclCount++
|
toolDeclCount++
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func ConvertClaudeResponseToOpenAIResponses(ctx context.Context, modelName strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// response.created
|
// response.created
|
||||||
created := `{"type":"response.created","sequence_number":0,"response":{"id":"","object":"response","created_at":0,"status":"in_progress","background":false,"error":null,"instructions":""}}`
|
created := `{"type":"response.created","sequence_number":0,"response":{"id":"","object":"response","created_at":0,"status":"in_progress","background":false,"error":null,"output":[]}}`
|
||||||
created, _ = sjson.Set(created, "sequence_number", nextSeq())
|
created, _ = sjson.Set(created, "sequence_number", nextSeq())
|
||||||
created, _ = sjson.Set(created, "response.id", st.ResponseID)
|
created, _ = sjson.Set(created, "response.id", st.ResponseID)
|
||||||
created, _ = sjson.Set(created, "response.created_at", st.CreatedAt)
|
created, _ = sjson.Set(created, "response.created_at", st.CreatedAt)
|
||||||
@@ -197,11 +197,11 @@ func ConvertClaudeResponseToOpenAIResponses(ctx context.Context, modelName strin
|
|||||||
if st.ReasoningActive {
|
if st.ReasoningActive {
|
||||||
if t := d.Get("thinking"); t.Exists() {
|
if t := d.Get("thinking"); t.Exists() {
|
||||||
st.ReasoningBuf.WriteString(t.String())
|
st.ReasoningBuf.WriteString(t.String())
|
||||||
msg := `{"type":"response.reasoning_summary_text.delta","sequence_number":0,"item_id":"","output_index":0,"summary_index":0,"text":""}`
|
msg := `{"type":"response.reasoning_summary_text.delta","sequence_number":0,"item_id":"","output_index":0,"summary_index":0,"delta":""}`
|
||||||
msg, _ = sjson.Set(msg, "sequence_number", nextSeq())
|
msg, _ = sjson.Set(msg, "sequence_number", nextSeq())
|
||||||
msg, _ = sjson.Set(msg, "item_id", st.ReasoningItemID)
|
msg, _ = sjson.Set(msg, "item_id", st.ReasoningItemID)
|
||||||
msg, _ = sjson.Set(msg, "output_index", st.ReasoningIndex)
|
msg, _ = sjson.Set(msg, "output_index", st.ReasoningIndex)
|
||||||
msg, _ = sjson.Set(msg, "text", t.String())
|
msg, _ = sjson.Set(msg, "delta", t.String())
|
||||||
out = append(out, emitEvent("response.reasoning_summary_text.delta", msg))
|
out = append(out, emitEvent("response.reasoning_summary_text.delta", msg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ func ConvertClaudeRequestToCLI(modelName string, inputRawJSON []byte, _ bool) []
|
|||||||
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
||||||
tool, _ = sjson.Delete(tool, "strict")
|
tool, _ = sjson.Delete(tool, "strict")
|
||||||
tool, _ = sjson.Delete(tool, "input_examples")
|
tool, _ = sjson.Delete(tool, "input_examples")
|
||||||
|
tool, _ = sjson.Delete(tool, "type")
|
||||||
|
tool, _ = sjson.Delete(tool, "cache_control")
|
||||||
var toolDeclaration any
|
var toolDeclaration any
|
||||||
if err := json.Unmarshal([]byte(tool), &toolDeclaration); err == nil {
|
if err := json.Unmarshal([]byte(tool), &toolDeclaration); err == nil {
|
||||||
tools[0].FunctionDeclarations = append(tools[0].FunctionDeclarations, toolDeclaration)
|
tools[0].FunctionDeclarations = append(tools[0].FunctionDeclarations, toolDeclaration)
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ func ConvertClaudeRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
||||||
tool, _ = sjson.Delete(tool, "strict")
|
tool, _ = sjson.Delete(tool, "strict")
|
||||||
tool, _ = sjson.Delete(tool, "input_examples")
|
tool, _ = sjson.Delete(tool, "input_examples")
|
||||||
|
tool, _ = sjson.Delete(tool, "type")
|
||||||
|
tool, _ = sjson.Delete(tool, "cache_control")
|
||||||
var toolDeclaration any
|
var toolDeclaration any
|
||||||
if err := json.Unmarshal([]byte(tool), &toolDeclaration); err == nil {
|
if err := json.Unmarshal([]byte(tool), &toolDeclaration); err == nil {
|
||||||
tools[0].FunctionDeclarations = append(tools[0].FunctionDeclarations, toolDeclaration)
|
tools[0].FunctionDeclarations = append(tools[0].FunctionDeclarations, toolDeclaration)
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func ConvertGeminiResponseToOpenAIResponses(_ context.Context, modelName string,
|
|||||||
st.CreatedAt = time.Now().Unix()
|
st.CreatedAt = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
created := `{"type":"response.created","sequence_number":0,"response":{"id":"","object":"response","created_at":0,"status":"in_progress","background":false,"error":null}}`
|
created := `{"type":"response.created","sequence_number":0,"response":{"id":"","object":"response","created_at":0,"status":"in_progress","background":false,"error":null,"output":[]}}`
|
||||||
created, _ = sjson.Set(created, "sequence_number", nextSeq())
|
created, _ = sjson.Set(created, "sequence_number", nextSeq())
|
||||||
created, _ = sjson.Set(created, "response.id", st.ResponseID)
|
created, _ = sjson.Set(created, "response.id", st.ResponseID)
|
||||||
created, _ = sjson.Set(created, "response.created_at", st.CreatedAt)
|
created, _ = sjson.Set(created, "response.created_at", st.CreatedAt)
|
||||||
@@ -160,11 +160,11 @@ func ConvertGeminiResponseToOpenAIResponses(_ context.Context, modelName string,
|
|||||||
}
|
}
|
||||||
if t := part.Get("text"); t.Exists() && t.String() != "" {
|
if t := part.Get("text"); t.Exists() && t.String() != "" {
|
||||||
st.ReasoningBuf.WriteString(t.String())
|
st.ReasoningBuf.WriteString(t.String())
|
||||||
msg := `{"type":"response.reasoning_summary_text.delta","sequence_number":0,"item_id":"","output_index":0,"summary_index":0,"text":""}`
|
msg := `{"type":"response.reasoning_summary_text.delta","sequence_number":0,"item_id":"","output_index":0,"summary_index":0,"delta":""}`
|
||||||
msg, _ = sjson.Set(msg, "sequence_number", nextSeq())
|
msg, _ = sjson.Set(msg, "sequence_number", nextSeq())
|
||||||
msg, _ = sjson.Set(msg, "item_id", st.ReasoningItemID)
|
msg, _ = sjson.Set(msg, "item_id", st.ReasoningItemID)
|
||||||
msg, _ = sjson.Set(msg, "output_index", st.ReasoningIndex)
|
msg, _ = sjson.Set(msg, "output_index", st.ReasoningIndex)
|
||||||
msg, _ = sjson.Set(msg, "text", t.String())
|
msg, _ = sjson.Set(msg, "delta", t.String())
|
||||||
out = append(out, emitEvent("response.reasoning_summary_text.delta", msg))
|
out = append(out, emitEvent("response.reasoning_summary_text.delta", msg))
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ func ConvertOpenAIChatCompletionsResponseToOpenAIResponses(ctx context.Context,
|
|||||||
st.ReasoningTokens = 0
|
st.ReasoningTokens = 0
|
||||||
st.UsageSeen = false
|
st.UsageSeen = false
|
||||||
// response.created
|
// response.created
|
||||||
created := `{"type":"response.created","sequence_number":0,"response":{"id":"","object":"response","created_at":0,"status":"in_progress","background":false,"error":null}}`
|
created := `{"type":"response.created","sequence_number":0,"response":{"id":"","object":"response","created_at":0,"status":"in_progress","background":false,"error":null,"output":[]}}`
|
||||||
created, _ = sjson.Set(created, "sequence_number", nextSeq())
|
created, _ = sjson.Set(created, "sequence_number", nextSeq())
|
||||||
created, _ = sjson.Set(created, "response.id", st.ResponseID)
|
created, _ = sjson.Set(created, "response.id", st.ResponseID)
|
||||||
created, _ = sjson.Set(created, "response.created_at", st.Created)
|
created, _ = sjson.Set(created, "response.created_at", st.Created)
|
||||||
@@ -216,11 +216,11 @@ func ConvertOpenAIChatCompletionsResponseToOpenAIResponses(ctx context.Context,
|
|||||||
}
|
}
|
||||||
// Append incremental text to reasoning buffer
|
// Append incremental text to reasoning buffer
|
||||||
st.ReasoningBuf.WriteString(rc.String())
|
st.ReasoningBuf.WriteString(rc.String())
|
||||||
msg := `{"type":"response.reasoning_summary_text.delta","sequence_number":0,"item_id":"","output_index":0,"summary_index":0,"text":""}`
|
msg := `{"type":"response.reasoning_summary_text.delta","sequence_number":0,"item_id":"","output_index":0,"summary_index":0,"delta":""}`
|
||||||
msg, _ = sjson.Set(msg, "sequence_number", nextSeq())
|
msg, _ = sjson.Set(msg, "sequence_number", nextSeq())
|
||||||
msg, _ = sjson.Set(msg, "item_id", st.ReasoningID)
|
msg, _ = sjson.Set(msg, "item_id", st.ReasoningID)
|
||||||
msg, _ = sjson.Set(msg, "output_index", st.ReasoningIndex)
|
msg, _ = sjson.Set(msg, "output_index", st.ReasoningIndex)
|
||||||
msg, _ = sjson.Set(msg, "text", rc.String())
|
msg, _ = sjson.Set(msg, "delta", rc.String())
|
||||||
out = append(out, emitRespEvent("response.reasoning_summary_text.delta", msg))
|
out = append(out, emitRespEvent("response.reasoning_summary_text.delta", msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user