| 264 | } |
| 265 | |
| 266 | func parseTestResponse(resp string) (*openai.TextResponse, string, string, error) { |
| 267 | var response openai.TextResponse |
| 268 | err := json.Unmarshal([]byte(resp), &response) |
| 269 | if err != nil { |
| 270 | return nil, "", "", err |
| 271 | } |
| 272 | if len(response.Choices) == 0 { |
| 273 | return nil, "", "", errors.New("response has no choices") |
| 274 | } |
| 275 | stringContent, ok := response.Choices[0].Content.(string) |
| 276 | if !ok { |
| 277 | return nil, "", "", errors.New("response content is not string") |
| 278 | } |
| 279 | return &response, stringContent, response.Model, nil |
| 280 | } |
| 281 | |
| 282 | func buildTestRequest(model string) *relaymodel.GeneralOpenAIRequest { |
| 283 | if model == "" { |