Separate required and optional args.

This commit is contained in:
Haiping Chen 2023-10-30 12:44:53 -05:00
parent 3caa7a5499
commit df7743e37d
3 changed files with 25 additions and 9 deletions

View file

@ -13,6 +13,9 @@ public class RoutingItem
[JsonPropertyName("description")] [JsonPropertyName("description")]
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
[JsonPropertyName("fields")] [JsonPropertyName("required_fields")]
public List<ParameterPropertyDef> Fields { get; set; } = new List<ParameterPropertyDef>(); public List<ParameterPropertyDef> RequiredFields { get; set; } = new List<ParameterPropertyDef>();
[JsonPropertyName("optional_fields")]
public List<ParameterPropertyDef> OptionalFields { get; set; } = new List<ParameterPropertyDef>();
} }

View file

@ -92,7 +92,14 @@ public class RouterInstance : IRouterInstance
AgentId = x.Id, AgentId = x.Id,
Description = x.Description, Description = x.Description,
Name = x.Name, Name = x.Name,
Fields = x.RoutingRules RequiredFields = x.RoutingRules
.Where(p => p.Required)
.Select(p => new ParameterPropertyDef(p.Field, p.Description, type: p.Type)
{
Required = p.Required
}).ToList(),
OptionalFields = x.RoutingRules
.Where(p => !p.Required)
.Select(p => new ParameterPropertyDef(p.Field, p.Description, type: p.Type) .Select(p => new ParameterPropertyDef(p.Field, p.Description, type: p.Type)
{ {
Required = p.Required Required = p.Required

View file

@ -19,12 +19,18 @@ Parameters:
[AGENTS] [AGENTS]
{% for agent in routing_agents %} {% for agent in routing_agents %}
* {{ agent.description}} * Agent: {{ agent.name }}
Agent: {{ agent.name }} {{ agent.description}}
{% if agent.fields and agent.fields != empty -%} {% if agent.required_fields and agent.required_fields != empty -%}
Arguments: Required args:
{% for f in agent.fields -%} {% for f in agent.required_fields -%}
- {{ f.name }}: {{ f.description }} (type: {{ f.type }}, required: {{f.required}}){{ "\r\n " }} - {{ f.name }} (type: {{ f.type }}): {{ f.description }}{{ "\r\n " }}
{%- endfor %}
{%- endif %}
{% if agent.optional_fields and agent.optional_fields != empty -%}
Optional args:
{% for f in agent.optional_fields -%}
- {{ f.name }} (type: {{ f.type }}): {{ f.description }}{{ "\r\n " }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{% endfor %} {% endfor %}