mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-12 13:27:06 +00:00
feat: support openai organization Id (#1133)
* feat: add organization flag Signed-off-by: JuHyung-Son <sonju0427@gmail.com> * feat: add orgId on openai backend Signed-off-by: JuHyung-Son <sonju0427@gmail.com> --------- Signed-off-by: JuHyung-Son <sonju0427@gmail.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
This commit is contained in:
@@ -27,10 +27,11 @@ const openAIClientName = "openai"
|
||||
type OpenAIClient struct {
|
||||
nopCloser
|
||||
|
||||
client *openai.Client
|
||||
model string
|
||||
temperature float32
|
||||
topP float32
|
||||
client *openai.Client
|
||||
model string
|
||||
temperature float32
|
||||
topP float32
|
||||
organizationId string
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -43,6 +44,7 @@ const (
|
||||
func (c *OpenAIClient) Configure(config IAIConfig) error {
|
||||
token := config.GetPassword()
|
||||
defaultConfig := openai.DefaultConfig(token)
|
||||
orgId := config.GetOrganizationId()
|
||||
proxyEndpoint := config.GetProxyEndpoint()
|
||||
|
||||
baseURL := config.GetBaseURL()
|
||||
@@ -64,6 +66,10 @@ func (c *OpenAIClient) Configure(config IAIConfig) error {
|
||||
}
|
||||
}
|
||||
|
||||
if orgId != "" {
|
||||
defaultConfig.OrgID = orgId
|
||||
}
|
||||
|
||||
client := openai.NewClientWithConfig(defaultConfig)
|
||||
if client == nil {
|
||||
return errors.New("error creating OpenAI client")
|
||||
|
Reference in New Issue
Block a user