mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-04 22:51:47 +01:00
🎨 AI supports configuration randomness and context number https://github.com/siyuan-note/siyuan/issues/10660
This commit is contained in:
parent
97e3ff656d
commit
a7e1e3abac
12 changed files with 66 additions and 16 deletions
|
|
@ -29,15 +29,16 @@ type AI struct {
|
|||
}
|
||||
|
||||
type OpenAI struct {
|
||||
APIKey string `json:"apiKey"`
|
||||
APITimeout int `json:"apiTimeout"`
|
||||
APIProxy string `json:"apiProxy"`
|
||||
APIModel string `json:"apiModel"`
|
||||
APIMaxTokens int `json:"apiMaxTokens"`
|
||||
APIBaseURL string `json:"apiBaseURL"`
|
||||
APIUserAgent string `json:"apiUserAgent"`
|
||||
APIProvider string `json:"apiProvider"` // OpenAI, Azure
|
||||
APIVersion string `json:"apiVersion"` // Azure API version
|
||||
APIKey string `json:"apiKey"`
|
||||
APITimeout int `json:"apiTimeout"`
|
||||
APIProxy string `json:"apiProxy"`
|
||||
APIModel string `json:"apiModel"`
|
||||
APIMaxTokens int `json:"apiMaxTokens"`
|
||||
APITemperature float64 `json:"apiTemperature"`
|
||||
APIBaseURL string `json:"apiBaseURL"`
|
||||
APIUserAgent string `json:"apiUserAgent"`
|
||||
APIProvider string `json:"apiProvider"` // OpenAI, Azure
|
||||
APIVersion string `json:"apiVersion"` // Azure API version
|
||||
}
|
||||
|
||||
func NewAI() *AI {
|
||||
|
|
@ -69,6 +70,13 @@ func NewAI() *AI {
|
|||
}
|
||||
}
|
||||
|
||||
if temperature := os.Getenv("SIYUAN_OPENAI_API_TEMPERATURE"); "" != temperature {
|
||||
temperatureFloat, err := strconv.ParseFloat(temperature, 64)
|
||||
if nil == err {
|
||||
openAI.APITemperature = temperatureFloat
|
||||
}
|
||||
}
|
||||
|
||||
if baseURL := os.Getenv("SIYUAN_OPENAI_API_BASE_URL"); "" != baseURL {
|
||||
openAI.APIBaseURL = baseURL
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue