Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
d3f17d2a
Commit
d3f17d2a
authored
Aug 17, 2026
by
段廷瑞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pref: Agent配置统一到默认路径
parent
63b72095
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
+32
-3
AgentConfig.json
AppHome/Agent/config/AgentConfig.json
+1
-0
wMyAgent.cs
Tools/MyAgent/wMyAgent.cs
+31
-3
No files found.
AppHome/Agent/config/AgentConfig.json
0 → 100644
View file @
d3f17d2a
{
"ApiKey"
:
"sk-bfaffa679dac4f7e9b2f128ee022022d"
,
"BaseUrl"
:
"https://api.deepseek.com"
,
"Model"
:
"deepseek-v4-flash"
,
"KnowledgeBasePath"
:
"D:
\\
working
\\
docs
\\
个人文档"
,
"Temperature"
:
0.3
,
"MaxTokens"
:
2048
}
\ No newline at end of file
Tools/MyAgent/wMyAgent.cs
View file @
d3f17d2a
...
...
@@ -82,9 +82,36 @@ namespace Tools.MyAgent
/// <summary>默认知识库路径:程序输出目录下的 Agent 文件夹(未设置知识库时生效)</summary>
private
static
string
DefaultKbRoot
=>
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Agent"
);
/// <summary>Agent 配置文件:默认 Agent 目录下的 config\AgentConfig.json</summary>
private
static
string
AgentConfigFilePath
=>
Path
.
Combine
(
DefaultKbRoot
,
"config"
,
"AgentConfig.json"
);
/// <summary>读取 Agent 配置文件(默认 Agent 目录下 config 文件夹)</summary>
private
AgentConfig
LoadAgentConfig
()
{
try
{
if
(
File
.
Exists
(
AgentConfigFilePath
))
return
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
AgentConfig
>(
File
.
ReadAllText
(
AgentConfigFilePath
,
System
.
Text
.
Encoding
.
UTF8
));
}
catch
{
}
return
null
;
}
/// <summary>保存 Agent 配置文件到默认 Agent 目录下 config 文件夹</summary>
private
void
SaveAgentConfig
(
AgentConfig
cfg
)
{
try
{
Directory
.
CreateDirectory
(
Path
.
Combine
(
DefaultKbRoot
,
"config"
));
File
.
WriteAllText
(
AgentConfigFilePath
,
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
cfg
),
System
.
Text
.
Encoding
.
UTF8
);
}
catch
{
}
}
private
void
LoadConfig
()
{
_config
=
Utils
.
GetJsonConfig
<
AgentConfig
>()
??
new
AgentConfig
();
// 统一使用默认 Agent 目录下 config 文件夹的 AgentConfig.json(新位置)
_config
=
LoadAgentConfig
()
??
new
AgentConfig
();
// 模型归一化:仅允许支持的模型,旧值回退到默认
if
(!
SupportedModels
.
Contains
(
_config
.
Model
??
""
))
_config
.
Model
=
SupportedModels
[
0
];
...
...
@@ -102,7 +129,8 @@ namespace Tools.MyAgent
private
void
SaveConfig
()
{
Utils
.
SaveJsonConfig
(
_config
);
// 统一保存到默认 Agent 目录下 config 文件夹(唯一位置)
SaveAgentConfig
(
_config
);
}
private
void
ApplyConfig
()
...
...
@@ -809,7 +837,7 @@ namespace Tools.MyAgent
};
var
lblHint
=
new
Label
{
Text
=
"API Key 仅保存在本机 config\\AgentConfig.json"
,
Text
=
"API Key 仅保存在本机
Agent\\
config\\AgentConfig.json"
,
AutoSize
=
true
,
ForeColor
=
Color
.
Gray
,
Location
=
new
Point
(
150
,
160
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment