初始提交
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
using MAF1.PluginContract;
|
||||
|
||||
namespace MAF1.Web;
|
||||
|
||||
public sealed class PortInfo
|
||||
{
|
||||
public string Name { get; init; } = "";
|
||||
public string Type { get; init; } = "";
|
||||
public string Description { get; init; } = "";
|
||||
public bool Required { get; init; }
|
||||
}
|
||||
|
||||
public sealed class AgentTypeInfo
|
||||
{
|
||||
public string Type { get; init; } = "";
|
||||
public string Name { get; init; } = "";
|
||||
public string Description { get; init; } = "";
|
||||
public string Origin { get; set; } = "system";
|
||||
public string Version { get; init; } = "";
|
||||
public string Folder { get; init; } = "";
|
||||
public bool Overridden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程内实现。系统节点必填;插件节点为 None,走独立进程。
|
||||
/// </summary>
|
||||
public SystemHandler Handler { get; init; }
|
||||
|
||||
public IReadOnlyList<PortInfo> Inputs { get; init; } = [];
|
||||
public IReadOnlyList<PortInfo> Outputs { get; init; } = [];
|
||||
public IReadOnlyList<PluginCredentialNeed> Credentials { get; init; } = [];
|
||||
}
|
||||
|
||||
public enum SystemHandler
|
||||
{
|
||||
None = 0,
|
||||
FileCity,
|
||||
Weather,
|
||||
}
|
||||
|
||||
public static class AgentCatalog
|
||||
{
|
||||
public static AgentTypeInfo? FindSystem(string type)
|
||||
=> SystemNodes.FirstOrDefault(item => item.Type.Equals(type, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
public static IReadOnlyList<AgentTypeInfo> SystemNodes { get; } =
|
||||
[
|
||||
new()
|
||||
{
|
||||
Type = "fileCity-system",
|
||||
Name = "FileCityAgent-System",
|
||||
Description = "读取指定文本文件,判断并抽出有效城市名(系统内置实现)。",
|
||||
Origin = "system",
|
||||
Handler = SystemHandler.FileCity,
|
||||
Inputs =
|
||||
[
|
||||
new PortInfo { Name = "filePath", Type = "string", Description = "本地文件路径,例如 Data/cities.txt", Required = true },
|
||||
],
|
||||
Outputs =
|
||||
[
|
||||
new PortInfo { Name = "hasValidCities", Type = "bool", Description = "是否存在有效城市" },
|
||||
new PortInfo { Name = "cities", Type = "string[]", Description = "有效城市名列表" },
|
||||
new PortInfo { Name = "reason", Type = "string", Description = "判断说明" },
|
||||
new PortInfo { Name = "raw", Type = "string", Description = "Agent 原始文本" },
|
||||
],
|
||||
Credentials =
|
||||
[
|
||||
new PluginCredentialNeed
|
||||
{
|
||||
Name = "llm",
|
||||
Type = "openai-compatible",
|
||||
Required = true,
|
||||
Description = "OpenAI 兼容接口:endpoint + apiKey + model",
|
||||
},
|
||||
],
|
||||
},
|
||||
new()
|
||||
{
|
||||
Type = "weather-system",
|
||||
Name = "WeatherAgent-System",
|
||||
Description = "按城市列表查询天气并汇总(系统内置实现)。",
|
||||
Origin = "system",
|
||||
Handler = SystemHandler.Weather,
|
||||
Inputs =
|
||||
[
|
||||
new PortInfo { Name = "cities", Type = "string[]", Description = "要查询的城市名列表", Required = true },
|
||||
],
|
||||
Outputs =
|
||||
[
|
||||
new PortInfo { Name = "summary", Type = "string", Description = "天气汇总文本" },
|
||||
],
|
||||
Credentials =
|
||||
[
|
||||
new PluginCredentialNeed
|
||||
{
|
||||
Name = "llm",
|
||||
Type = "openai-compatible",
|
||||
Required = true,
|
||||
Description = "OpenAI 兼容接口:endpoint + apiKey + model",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user