-
Notifications
You must be signed in to change notification settings - Fork 2k
Feature aichat 20250730 and new plugin aiimage
#1187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guohuiyuan
wants to merge
15
commits into
FloatTech:master
Choose a base branch
from
guohuiyuan:feature-aichat-20250730
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8d2dffb
✨ 添加重置聊天
guohuiyuan 8feca47
🎨 优化使用提示
guohuiyuan e5a7c30
✨ 添加群聊摘要
guohuiyuan eae8383
🐛 修复读配置bug
guohuiyuan 3eadcc3
🐛 修改wordcount的问题
guohuiyuan 9e98b8f
🐛 修复查询水群bug
guohuiyuan c72a5d2
🎨 热词限制当前群聊
guohuiyuan 0ec6480
🎨 token消耗大,添加admin权限
guohuiyuan c690405
🎨 转发分段
guohuiyuan 307f66f
✨ 添加ai画图
guohuiyuan 334363c
🎨 readme添加ai画图
guohuiyuan 958be34
✨ 添加校验
guohuiyuan bd53c19
🎨 更新zbputils
guohuiyuan 8945e97
Merge branch 'FloatTech:master' into feature-aichat-20250730
guohuiyuan 2b6a08c
🎨 优化ai画图代码
guohuiyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Package aiimage 提供AI画图功能配置 | ||
package aiimage | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"sync" | ||
|
||
sql "github.com/FloatTech/sqlite" | ||
) | ||
|
||
// storage 管理画图配置存储 | ||
type storage struct { | ||
sync.RWMutex | ||
db sql.Sqlite | ||
} | ||
|
||
// imageConfig 存储AI画图配置信息 | ||
type imageConfig struct { | ||
ID int64 `db:"id"` // 主键ID | ||
APIKey string `db:"apiKey"` // API密钥 | ||
APIURL string `db:"apiUrl"` // API地址 | ||
ModelName string `db:"modelName"` // 画图模型名称 | ||
} | ||
|
||
// getConfig 获取当前配置 | ||
func (sdb *storage) getConfig() imageConfig { | ||
sdb.RLock() | ||
defer sdb.RUnlock() | ||
cfg := imageConfig{} | ||
_ = sdb.db.Find("config", &cfg, "WHERE id = 1") | ||
return cfg | ||
} | ||
|
||
// setConfig 设置AI画图配置 | ||
func (sdb *storage) setConfig(apiKey, apiURL, modelName string) error { | ||
sdb.Lock() | ||
defer sdb.Unlock() | ||
return sdb.db.Insert("config", &imageConfig{ | ||
ID: 1, | ||
APIKey: apiKey, | ||
APIURL: apiURL, | ||
ModelName: modelName, | ||
}) | ||
} | ||
|
||
// PrintConfig 返回格式化后的配置信息 | ||
func (sdb *storage) PrintConfig() string { | ||
cfg := sdb.getConfig() | ||
var builder strings.Builder | ||
builder.WriteString("当前AI画图配置:\n") | ||
builder.WriteString(fmt.Sprintf("• 密钥: %s\n", cfg.APIKey)) | ||
builder.WriteString(fmt.Sprintf("• 接口地址: %s\n", cfg.APIURL)) | ||
builder.WriteString(fmt.Sprintf("• 模型名: %s\n", cfg.ModelName)) | ||
return builder.String() | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无效的封装。应当是
然后在
sdb.getConfig
中上锁。锁不要暴露给调用者。其他位置同理。