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