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:
JuHyung Son
2024-06-14 16:39:56 +09:00
committed by GitHub
parent c834c09996
commit 4867d39c66
6 changed files with 72 additions and 44 deletions

View File

@@ -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")