Configuration
The Next Gen UI Agent can be configured in two ways: programmatically using Python dictionaries or declaratively using YAML configuration files.
Agent configuration JSON Schema and how to use it to validate YAML files in IDE is described here.
Configuration Options
component_system [str, optional]
UI Component system for rendering (default: "json")
data_transformer [str, optional]
Optional name of the Input Data Transformer used by the UI Agent. Can be overriden per data type. Defaults to JSON.
unsupported_components [bool, optional]
Whether to allow unsupported/Tech Preview Dynamic UI components to be selected by LLM (default: False)
component_selection_strategy [str, optional]
Strategy for LLM powered component selection and configuration step:
one_llm_call: Uses single LLM call for component selection and configuration - defaulttwo_llm_calls: Uses two LLM calls - first selects component type, second configures it - experimental feature!
input_data_json_wrapping [bool, optional]
Whether to perform automatic InputData JSON wrapping if JSON structure is not good for LLM processing (default: True)
data_types [dict[str, AgentConfigDataType], optional]
Configurations for InputData.types, like:
- input data transformation
- list of components to render this data type
Key is InputData.type to configure, value is configuration object for that data type:
data_transformer [str, optional]
Optional name of the Input Data Transformer to be used for this data type instead of Agent's default one.
components [list[AgentConfigComponent], optional]
Optional list of components used to render this data type. See description of the component selection process.
For now only one component can be defined in this list, and it has to be:
- Dynamic component with pre-defined configuration
- Hand Build Component
In the future, we plan plan to implement additional component selection features so this configuration will be extended.
component [str, required]
Name of the UI component. Identification of the supported Dynamic Component can be used here. Other value is interpreted as Hand Build Component name and HBC is rendered.
configuration [AgentConfigDynamicComponentConfiguration, optional]
If Dynamic Component is named, then its pre-defined configuration has to be provided here.
title [str, required]
Title of the component to be rendered in UI.
fields [list[DataField], required]
Fields of the UI component in the same format as generated by the LLM. Data transformation step is performed to pick-up Input Data values for UI rendering, so consult it for individual components specifics.
# name [str, required]
Name of the field rendered in UI. Can be used as a name of column in the table, or name of the fact in the card.
# data_path [str, required]
JSON Path pointer to Input Data structure to pick up values for UI rendering.
Programmatic Configuration
Usage with Inference Configuration
from next_gen_ui_agent import NextGenUIAgent, LangChainModelInference
from langchain_ollama import ChatOllama
# Configure LLM inference
llm = ChatOllama(model="llama3.2")
inference = LangChainModelInference(llm)
# Create configuration
config = {
"component_system": "json",
"component_selection_strategy": "default",
"unsupported_components": True
}
agent = NextGenUIAgent(config=config)
With Hand-Built Components
config = {
"component_system": "json",
"data_types": {
"movies:movie-detail": { components : [{ componnet: "movies:movie-detail-view"}]},
"movies:movies-list": { components : [{ componnet: "movies:movies-list-view"}]},
}
}
agent = NextGenUIAgent(config=config)
YAML Configuration
Basic YAML Configuration
Create a YAML configuration file:
---
component_system: json
unsupported_components: false
component_selection_strategy: default
data_types:
movies:movie-detail:
components:
- component: movies:movie-detail-view
movies:movies-list:
components:
- component: movies:movies-list-view
Loading YAML Configuration
You can load one or several YAML config files which are merged into one configuration where the last config has the highest precedense.
Field data_types is merged so having different keys in different yamls are merged into one data_types configuration.
From File Path
from next_gen_ui_agent import NextGenUIAgent
from next_gen_ui_agent.agent_config import read_config_yaml_file
# Load configuration from files
config = read_config_yaml_file(["path/to/config.yaml", "/path/to/config2.yaml"])
agent = NextGenUIAgent(config=config)