(model string, endpointType string, channel *model.Channel, isStream bool)
| 693 | } |
| 694 | |
| 695 | func buildTestRequest(model string, endpointType string, channel *model.Channel, isStream bool) dto.Request { |
| 696 | testResponsesInput := json.RawMessage(`[{"role":"user","content":"hi"}]`) |
| 697 | |
| 698 | // 根据端点类型构建不同的测试请求 |
| 699 | if endpointType != "" { |
| 700 | switch constant.EndpointType(endpointType) { |
| 701 | case constant.EndpointTypeEmbeddings: |
| 702 | // 返回 EmbeddingRequest |
| 703 | return &dto.EmbeddingRequest{ |
| 704 | Model: model, |
| 705 | Input: []any{"hello world"}, |
| 706 | } |
| 707 | case constant.EndpointTypeImageGeneration: |
| 708 | // 返回 ImageRequest |
| 709 | return &dto.ImageRequest{ |
| 710 | Model: model, |
| 711 | Prompt: "a cute cat", |
| 712 | N: lo.ToPtr(uint(1)), |
| 713 | Size: "1024x1024", |
| 714 | } |
| 715 | case constant.EndpointTypeJinaRerank: |
| 716 | // 返回 RerankRequest |
| 717 | return &dto.RerankRequest{ |
| 718 | Model: model, |
| 719 | Query: "What is Deep Learning?", |
| 720 | Documents: []any{"Deep Learning is a subset of machine learning.", "Machine learning is a field of artificial intelligence."}, |
| 721 | TopN: lo.ToPtr(2), |
| 722 | } |
| 723 | case constant.EndpointTypeOpenAIResponse: |
| 724 | // 返回 OpenAIResponsesRequest |
| 725 | return &dto.OpenAIResponsesRequest{ |
| 726 | Model: model, |
| 727 | Input: json.RawMessage(`[{"role":"user","content":"hi"}]`), |
| 728 | Stream: lo.ToPtr(isStream), |
| 729 | } |
| 730 | case constant.EndpointTypeOpenAIResponseCompact: |
| 731 | // 返回 OpenAIResponsesCompactionRequest |
| 732 | return &dto.OpenAIResponsesCompactionRequest{ |
| 733 | Model: model, |
| 734 | Input: testResponsesInput, |
| 735 | } |
| 736 | case constant.EndpointTypeAnthropic, constant.EndpointTypeGemini, constant.EndpointTypeOpenAI: |
| 737 | // 返回 GeneralOpenAIRequest |
| 738 | maxTokens := uint(16) |
| 739 | if constant.EndpointType(endpointType) == constant.EndpointTypeGemini { |
| 740 | maxTokens = 3000 |
| 741 | } |
| 742 | req := &dto.GeneralOpenAIRequest{ |
| 743 | Model: model, |
| 744 | Stream: lo.ToPtr(isStream), |
| 745 | Messages: []dto.Message{ |
| 746 | { |
| 747 | Role: "user", |
| 748 | Content: "hi", |
| 749 | }, |
| 750 | }, |
| 751 | MaxTokens: lo.ToPtr(maxTokens), |
| 752 | } |
no test coverage detected