MCPcopy Index your code
hub / github.com/53AI/53AIHub / testImageGenerationChannel

Function testImageGenerationChannel

api/controller/channel-test.go:435–466  ·  view source on GitHub ↗

testImageGenerationChannel 测试图像生成渠道

(ctx context.Context, channel *model.Channel, modelName string)

Source from the content-addressed store, hash-verified

433
434// testImageGenerationChannel 测试图像生成渠道
435func testImageGenerationChannel(ctx context.Context, channel *model.Channel, modelName string) (responseMessage string, err error) {
436 // 记录测试日志
437 logger.SysLogf("开始测试图像生成渠道 #%d, 模型: %s", channel.ChannelID, modelName)
438
439 // 创建测试请求 - 使用简单的文本提示生成图像
440 testRequest := &relaymodel.GeneralOpenAIRequest{
441 Model: modelName,
442 }
443 testMessage := relaymodel.Message{
444 Role: "user",
445 Content: "Generate a simple image of a red circle on white background.",
446 }
447 testRequest.Messages = append(testRequest.Messages, testMessage)
448
449 // 使用现有的 testChannel 函数进行测试
450 // 图像生成模型通常也支持 chat 格式的请求
451 responseMessage, err, _, actualModel := testChannel(ctx, channel, testRequest)
452 if err != nil {
453 logger.SysErrorf("测试图像生成渠道失败: %v", err)
454 return "", fmt.Errorf("测试图像生成渠道失败: %v", err)
455 }
456
457 // 构建成功消息
458 if actualModel != "" && actualModel != modelName {
459 responseMessage = fmt.Sprintf("图像生成模型 %s 测试成功 (实际模型: %s)", modelName, actualModel)
460 } else {
461 responseMessage = fmt.Sprintf("图像生成模型 %s 测试成功", modelName)
462 }
463 logger.SysLogf("测试图像生成渠道成功: %s", responseMessage)
464
465 return responseMessage, nil
466}
467
468// boolPtr 返回 bool 指针
469func boolPtr(b bool) *bool {

Callers 1

TestChannelFunction · 0.85

Calls 2

testChannelFunction · 0.85
ErrorfMethod · 0.80

Tested by 1

TestChannelFunction · 0.68