(provider string, body []byte, isEmbedding bool)
| 73 | } |
| 74 | |
| 75 | func (s *Step) DecorateRequest(provider string, body []byte, isEmbedding bool) ([]byte, error) { |
| 76 | if provider != "azure" { |
| 77 | if isEmbedding { |
| 78 | embeddingsReq := &goopenai.EmbeddingRequest{} |
| 79 | |
| 80 | err := json.Unmarshal(body, embeddingsReq) |
| 81 | if err != nil { |
| 82 | return nil, err |
| 83 | } |
| 84 | |
| 85 | embeddingsReq.Model = goopenai.EmbeddingModel(s.Model) |
| 86 | |
| 87 | return json.Marshal(embeddingsReq) |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | if !isEmbedding { |
| 92 | completionReq := &goopenai.ChatCompletionRequest{} |
| 93 | |
| 94 | err := json.Unmarshal(body, completionReq) |
| 95 | if err != nil { |
| 96 | return nil, err |
| 97 | } |
| 98 | |
| 99 | completionReq.Model = s.Model |
| 100 | |
| 101 | s.DecorateChatCompletionRequest(completionReq) |
| 102 | |
| 103 | return json.Marshal(completionReq) |
| 104 | } |
| 105 | |
| 106 | return body, nil |
| 107 | } |
| 108 | |
| 109 | func (s *Step) DecorateChatCompletionRequest(req *goopenai.ChatCompletionRequest) { |
| 110 | if s == nil { |
no test coverage detected