Skip to content

Commit 6a73825

Browse files
authored
Check for update before return the description for openai-gpt agent (#332)
1 parent d996130 commit 6a73825

File tree

1 file changed

+13
-4
lines changed
  • shell/agents/AIShell.OpenAI.Agent

1 file changed

+13
-4
lines changed

shell/agents/AIShell.OpenAI.Agent/Agent.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ namespace AIShell.OpenAI.Agent;
99
public sealed class OpenAIAgent : ILLMAgent
1010
{
1111
public string Name => "openai-gpt";
12-
public string Description { private set; get; }
1312
public string SettingFile { private set; get; }
13+
public string Description
14+
{
15+
get
16+
{
17+
// Changes in setting could affect the agent description.
18+
ReloadSettings();
19+
return _description;
20+
}
21+
}
1422

1523
private const string SettingFileName = "openai.agent.json";
1624
private bool _reloadSettings;
1725
private bool _isDisposed;
1826
private string _configRoot;
1927
private string _historyRoot;
28+
private string _description;
2029
private Settings _settings;
2130
private FileSystemWatcher _watcher;
2231
private ChatService _chatService;
@@ -167,20 +176,20 @@ 1. Run '/agent config' to open the setting file.
167176
{
168177
string error = "The agent is currently not ready to serve queries, because there is no GPT defined. Please follow the steps below to configure the setting file properly before using this agent";
169178
string action = "Define the GPT(s)";
170-
Description = string.Format(DefaultDescription, error, action);
179+
_description = string.Format(DefaultDescription, error, action);
171180
return;
172181
}
173182

174183
if (_settings.Active is null)
175184
{
176185
string error = "Multiple GPTs are defined but the active GPT is not specified. You will be prompted to choose from the available GPTs when sending the first query. Or, if you want to set the active GPT in configuration, please follow the steps below";
177186
string action = "Set the 'Active' key";
178-
Description = string.Format(DefaultDescription, error, action);
187+
_description = string.Format(DefaultDescription, error, action);
179188
return;
180189
}
181190

182191
GPT active = _settings.Active;
183-
Description = $"Active GPT: {active.Name}. {active.Description}";
192+
_description = $"Active GPT: {active.Name}. {active.Description}";
184193
}
185194

186195
internal void ReloadSettings()

0 commit comments

Comments
 (0)