(request pluginruntime.ProtocolRequestContext)
| 215 | } |
| 216 | |
| 217 | func taskPluginImageResponseFormat(request pluginruntime.ProtocolRequestContext) string { |
| 218 | body, ok := request.Body.(map[string]any) |
| 219 | if !ok { |
| 220 | return "" |
| 221 | } |
| 222 | switch body["kind"] { |
| 223 | case string(pluginruntime.BodyJSON): |
| 224 | value, _ := body["value"].(map[string]any) |
| 225 | format, _ := value["response_format"].(string) |
| 226 | return strings.TrimSpace(format) |
| 227 | case string(pluginruntime.BodyMultipart), string(pluginruntime.BodyForm): |
| 228 | fields, _ := body["fields"].(map[string][]string) |
| 229 | if values := fields["response_format"]; len(values) > 0 { |
| 230 | return strings.TrimSpace(values[0]) |
| 231 | } |
| 232 | } |
| 233 | return "" |
| 234 | } |
| 235 | |
| 236 | // respondTaskPluginImageError writes an OpenAI error envelope for the Images |
| 237 | // API. DashScope failure bodies arrive as JSON {code, message}; their message |
no outgoing calls
no test coverage detected