mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: support set openai api host (#1292)
* Docker * feat: support set openai api host * fix css * fix eslint * use API in backend & put host check in plugin/openai * fix go-static-checks
This commit is contained in:
@ -19,4 +19,6 @@ type SystemStatus struct {
|
||||
// Customized server profile, including server name and external url.
|
||||
CustomizedProfile CustomizedProfile `json:"customizedProfile"`
|
||||
StorageServiceID int `json:"storageServiceId"`
|
||||
// OpenAI API Host
|
||||
OpenAIAPIHost string `json:"openAIApiHost"`
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ const (
|
||||
SystemSettingStorageServiceIDName SystemSettingName = "storageServiceId"
|
||||
// SystemSettingOpenAIAPIKeyName is the key type of OpenAI API key.
|
||||
SystemSettingOpenAIAPIKeyName SystemSettingName = "openAIApiKey"
|
||||
// SystemSettingOpenAIAPIHost is the key type of OpenAI API path.
|
||||
SystemSettingOpenAIAPIHost SystemSettingName = "openAIApiHost"
|
||||
)
|
||||
|
||||
// CustomizedProfile is the struct definition for SystemSettingCustomizedProfileName system setting item.
|
||||
@ -67,6 +69,8 @@ func (key SystemSettingName) String() string {
|
||||
return "storageServiceId"
|
||||
case SystemSettingOpenAIAPIKeyName:
|
||||
return "openAIApiKey"
|
||||
case SystemSettingOpenAIAPIHost:
|
||||
return "openAIApiHost"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -171,6 +175,12 @@ func (upsert SystemSettingUpsert) Validate() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal system setting openai api key value")
|
||||
}
|
||||
} else if upsert.Name == SystemSettingOpenAIAPIHost {
|
||||
value := ""
|
||||
err := json.Unmarshal([]byte(upsert.Value), &value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal system setting openai api host value")
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("invalid system setting name")
|
||||
}
|
||||
|
Reference in New Issue
Block a user