mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
Revert "fix: drop unsupported tools for Mimo 2.6 Flash"
This reverts commit 7194c49452.
This commit is contained in:
1 parent
7194c49452
commit
c75a792b8c
1 file changed
+1
-33
@@ -272,11 +272,7 @@ func (g *Gateway) prepareRouteBodies(from wire.Protocol, route models.Route, inp
|
||||
if tier == config.TierGo {
|
||||
baseURL = g.cfg.Upstream.Go
|
||||
}
|
||||
requestInput := input
|
||||
if from == wire.Responses && protocol != from && isMimo26Flash(route.ID) {
|
||||
requestInput = dropNonFunctionResponsesTools(input)
|
||||
}
|
||||
upstreamPayload, err := wire.PrepareRequest(from, protocol, requestInput, baseURL)
|
||||
upstreamPayload, err := wire.PrepareRequest(from, protocol, input, baseURL)
|
||||
if err != nil {
|
||||
if tier != route.Tier {
|
||||
// A fallback tier may use a stricter wire format than the
|
||||
@@ -299,34 +295,6 @@ func (g *Gateway) prepareRouteBodies(from wire.Protocol, route models.Route, inp
|
||||
return bodies, nil
|
||||
}
|
||||
|
||||
func isMimo26Flash(model string) bool {
|
||||
parts := strings.Split(strings.ToLower(strings.TrimSpace(model)), "/")
|
||||
return parts[len(parts)-1] == "mimo-v2.6-flash"
|
||||
}
|
||||
|
||||
func dropNonFunctionResponsesTools(input map[string]any) map[string]any {
|
||||
tools, ok := input["tools"].([]any)
|
||||
if !ok {
|
||||
return input
|
||||
}
|
||||
filtered := make([]any, 0, len(tools))
|
||||
for _, raw := range tools {
|
||||
tool, ok := raw.(map[string]any)
|
||||
if ok && jsonutil.StringAt(tool, "type") == "function" {
|
||||
filtered = append(filtered, raw)
|
||||
}
|
||||
}
|
||||
if len(filtered) == len(tools) {
|
||||
return input
|
||||
}
|
||||
request := make(map[string]any, len(input))
|
||||
for key, value := range input {
|
||||
request[key] = value
|
||||
}
|
||||
request["tools"] = filtered
|
||||
return request
|
||||
}
|
||||
|
||||
func copyErrorResponse(w http.ResponseWriter, protocol wire.Protocol, resp *http.Response, requestID string) {
|
||||
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4<<20))
|
||||
if retryAfter := resp.Header.Get("Retry-After"); retryAfter != "" {
|
||||
|
||||
Reference in new issue
Block a user