MCPcopy Create free account
hub / github.com/QuantumNous/new-api / taskPluginImageResponseFormat

Function taskPluginImageResponseFormat

controller/plugin_protocol_image.go:224–241  ·  view source on GitHub ↗
(request pluginruntime.ProtocolRequestContext)

Source from the content-addressed store, hash-verified

222}
223
224func 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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected