( ctx context.Context, t testing.TB, client *codersdk.ExperimentalClient, providerType codersdk.AIProviderType, apiKey string, baseURL string, )
| 15 | ) |
| 16 | |
| 17 | func createIntegrationAIProvider( |
| 18 | ctx context.Context, |
| 19 | t testing.TB, |
| 20 | client *codersdk.ExperimentalClient, |
| 21 | providerType codersdk.AIProviderType, |
| 22 | apiKey string, |
| 23 | baseURL string, |
| 24 | ) codersdk.AIProvider { |
| 25 | t.Helper() |
| 26 | if baseURL == "" { |
| 27 | baseURL = defaultIntegrationAIProviderBaseURL(providerType) |
| 28 | } |
| 29 | provider, err := client.CreateAIProvider(ctx, codersdk.CreateAIProviderRequest{ |
| 30 | Type: providerType, |
| 31 | Name: string(providerType) + "-" + uuid.NewString(), |
| 32 | DisplayName: aiProviderDisplayName(providerType), |
| 33 | Enabled: true, |
| 34 | BaseURL: baseURL, |
| 35 | APIKeys: []string{apiKey}, |
| 36 | }) |
| 37 | require.NoError(t, err) |
| 38 | return provider |
| 39 | } |
| 40 | |
| 41 | func defaultIntegrationAIProviderBaseURL(providerType codersdk.AIProviderType) string { |
| 42 | switch providerType { |
no test coverage detected