Skip to content

Check for update before return the description for the openai-gpt agent #332

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

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions shell/agents/AIShell.OpenAI.Agent/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@ namespace AIShell.OpenAI.Agent;
public sealed class OpenAIAgent : ILLMAgent
{
public string Name => "openai-gpt";
public string Description { private set; get; }
public string SettingFile { private set; get; }
public string Description
{
get
{
// Changes in setting could affect the agent description.
ReloadSettings();
return _description;
}
}

private const string SettingFileName = "openai.agent.json";
private bool _reloadSettings;
private bool _isDisposed;
private string _configRoot;
private string _historyRoot;
private string _description;
private Settings _settings;
private FileSystemWatcher _watcher;
private ChatService _chatService;
Expand Down Expand Up @@ -167,20 +176,20 @@ 1. Run '/agent config' to open the setting file.
{
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";
string action = "Define the GPT(s)";
Description = string.Format(DefaultDescription, error, action);
_description = string.Format(DefaultDescription, error, action);
return;
}

if (_settings.Active is null)
{
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";
string action = "Set the 'Active' key";
Description = string.Format(DefaultDescription, error, action);
_description = string.Format(DefaultDescription, error, action);
return;
}

GPT active = _settings.Active;
Description = $"Active GPT: {active.Name}. {active.Description}";
_description = $"Active GPT: {active.Name}. {active.Description}";
}

internal void ReloadSettings()
Expand Down
Loading