feat: implement memos chat backend function (#1934)

* feat: implment backend function

* eslint

* eslint

* eslint
This commit is contained in:
CorrectRoadH
2023-07-13 11:25:59 +08:00
committed by GitHub
parent 6adbb7419c
commit d8b6e92813
6 changed files with 172 additions and 0 deletions

View File

@ -37,6 +37,8 @@ const (
SystemSettingTelegramBotTokenName SystemSettingName = "telegram-bot-token"
// SystemSettingMemoDisplayWithUpdatedTsName is the name of memo display with updated ts.
SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts"
// SystemSettingOpenAIConfigName is the name of OpenAI config.
SystemSettingOpenAIConfigName SystemSettingName = "openai-config"
)
// CustomizedProfile is the struct definition for SystemSettingCustomizedProfileName system setting item.
@ -66,6 +68,11 @@ type SystemSetting struct {
Description string `json:"description"`
}
type OpenAIConfig struct {
Key string `json:"key"`
Host string `json:"host"`
}
type UpsertSystemSettingRequest struct {
Name SystemSettingName `json:"name"`
Value string `json:"value"`
@ -127,6 +134,11 @@ func (upsert UpsertSystemSettingRequest) Validate() error {
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
return fmt.Errorf(systemSettingUnmarshalError, settingName)
}
case SystemSettingOpenAIConfigName:
value := OpenAIConfig{}
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
return fmt.Errorf(systemSettingUnmarshalError, settingName)
}
case SystemSettingTelegramBotTokenName:
if upsert.Value == "" {
return nil