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

Function taskPluginImageResponseFormat

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

Source from the content-addressed store, hash-verified

215}
216
217func 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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected