Fetch the repository succeeded.
package openai
import (
"net/http"
)
const (
openaiAPIURLv1 = "https://api.openai.com/v1"
defaultEmptyMessagesLimit uint = 300
azureAPIPrefix = "openai"
azureDeploymentsPrefix = "deployments"
)
type APIType string
const (
APITypeOpenAI APIType = "OPEN_AI"
APITypeAzure APIType = "AZURE"
APITypeAzureAD APIType = "AZURE_AD"
)
const AzureAPIKeyHeader = "api-key"
// ClientConfig is a configuration of a client.
type ClientConfig struct {
authToken string
BaseURL string
OrgID string
APIType APIType
APIVersion string // required when APIType is APITypeAzure or APITypeAzureAD
Engine string // required when APIType is APITypeAzure or APITypeAzureAD
HTTPClient *http.Client
EmptyMessagesLimit uint
}
func DefaultConfig(authToken string) ClientConfig {
return ClientConfig{
authToken: authToken,
BaseURL: openaiAPIURLv1,
APIType: APITypeOpenAI,
OrgID: "",
HTTPClient: &http.Client{},
EmptyMessagesLimit: defaultEmptyMessagesLimit,
}
}
func DefaultAzureConfig(apiKey, baseURL, engine string) ClientConfig {
return ClientConfig{
authToken: apiKey,
BaseURL: baseURL,
OrgID: "",
APIType: APITypeAzure,
APIVersion: "2023-03-15-preview",
Engine: engine,
HTTPClient: &http.Client{},
EmptyMessagesLimit: defaultEmptyMessagesLimit,
}
}
func (ClientConfig) String() string {
return "<OpenAI API ClientConfig>"
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。