mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-25 23:10:05 +00:00
26 lines
535 B
Go
26 lines
535 B
Go
package ai
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"github.com/k8sgpt-ai/k8sgpt/pkg/ai/openai"
|
|
)
|
|
|
|
var AIProviderMap = map[string]IAI{
|
|
"openai": &openai.OpenAIClient{},
|
|
}
|
|
|
|
type IAI interface {
|
|
Configure(token string, language string) error
|
|
GetCompletion(ctx context.Context, prompt string) (string, error)
|
|
Parse(text string, prompt []string, nocache bool) (string, error)
|
|
}
|
|
|
|
func NewAIClient(provider string) (IAI, error) {
|
|
ai, ok := AIProviderMap[provider]
|
|
if !ok {
|
|
return nil, errors.New("AI provider not found")
|
|
}
|
|
return ai, nil
|
|
}
|