1 Star 0 Fork 0

糍粑 / funk-open-ai

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
config.go 1.40 KB
Copy Edit Raw Blame History
sashabaranov authored 2023-04-08 19:26 . Add form builder (#235)
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>"
}
Go
1
https://gitee.com/pc_859107393/funk-open-ai.git
git@gitee.com:pc_859107393/funk-open-ai.git
pc_859107393
funk-open-ai
funk-open-ai
v1.9.2

Search