Implementation:AGenUI AGenUI FunctionCallConfig
| Knowledge Sources | |
|---|---|
| Domains | Software_Architecture, UI_Framework |
| Last Updated | 2026-10-24 17:21 GMT |
Overview
Configuration data class for function calls, storing namespace, name, description, and return type metadata, provided by the AGenUI C++ core.
Description
The `FunctionCallConfig` class holds the metadata that describes a function call: its `namespace`, `name`, `description`, and `returnType`. It is used by `FunctionCallManager` to register and catalog function calls, and by `IFunctionCall::getConfig()` to self-describe built-in functions.
The class provides JSON serialization via `fromJson()` / `toJson()` and a `getFullName()` helper that returns `namespace::name` (or just `name` if no namespace). Validation (`isValid()`) requires only that `name` is non-empty.
Usage
- Host registration: construct from JSON config when registering a platform function via `engine->registerFunction(configJson, &myFunction)`.
- Builtin self-description: each `IFunctionCall` subclass returns a `FunctionCallConfig` from its `getConfig()` override.
- Catalog export: `FunctionCallManager::exportCatalog()` serializes all configs to JSON.
Code Reference
Source Location
- Repository: AGenUI
- Header: core/src/function_call/agenui_functioncall_config.h
- Implementation: `core/src/function_call/agenui_functioncall_config.cpp` (62 lines)
- Lines: Header L20-67, Implementation L1-62
Signature
// core/src/function_call/agenui_functioncall_config.h
namespace agenui {
class FunctionCallConfig {
public:
FunctionCallConfig();
~FunctionCallConfig();
/// Create a FunctionCallConfig from a JSON object
static FunctionCallConfig fromJson(const nlohmann::json& json);
/// Serialize to a JSON object
nlohmann::json toJson() const;
/// Check whether the configuration is valid (name must be non-empty)
bool isValid() const;
/// Get the fully qualified functionCall name (namespace::name)
std::string getFullName() const;
// Getters
const std::string& getNamespace() const;
const std::string& getName() const;
const std::string& getDescription() const;
const std::string& getReturnType() const;
// Setters
void setNamespace(const std::string& ns);
void setName(const std::string& name);
void setDescription(const std::string& desc);
void setReturnType(const std::string& type);
private:
std::string _namespace;
std::string _name;
std::string _description;
std::string _returnType;
};
} // namespace agenui
Import
#include "function_call/agenui_functioncall_config.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| json (fromJson) | `const nlohmann::json&` | Yes | JSON object with "namespace", "name", "description", "returnType" string fields |
| ns | `const std::string&` | No | Namespace for the function call (e.g. "agenui.platform") |
| name | `const std::string&` | Yes | Short function name (e.g. "toast") |
| desc | `const std::string&` | No | Human-readable description |
| type | `const std::string&` | No | Return type string (e.g. "object", "string") |
Outputs
| Name | Type | Description |
|---|---|---|
| fromJson returns | `FunctionCallConfig` | Parsed config instance |
| toJson returns | `nlohmann::json` | JSON object with namespace, name, description, returnType |
| getFullName returns | `std::string` | "namespace::name" or just "name" if no namespace |
| isValid returns | `bool` | True if name is non-empty |
Usage Examples
Creating a Config from JSON
#include "function_call/agenui_functioncall_config.h"
nlohmann::json configJson = R"({
"namespace": "agenui.platform",
"name": "toast",
"description": "Show a Toast message",
"returnType": "object"
})"_json;
auto config = agenui::FunctionCallConfig::fromJson(configJson);
// Validate
if (!config.isValid()) {
printf("Invalid config: name is empty\n");
return;
}
printf("Full name: %s\n", config.getFullName().c_str());
// Output: agenui.platform::toast
Building a Config Programmatically
agenui::FunctionCallConfig config;
config.setNamespace("agenui.format");
config.setName("formatDate");
config.setDescription("Formats a timestamp into a string using a pattern.");
config.setReturnType("string");
// Serialize to JSON for catalog export
nlohmann::json json = config.toJson();
printf("Catalog entry: %s\n", json.dump(2).c_str());
Related Pages
Implements Principle
Requires Environment
Related Implementations
- Implementation:AGenUI_AGenUI_FunctionCallManager — uses FunctionCallConfig for registration and catalog
- Implementation:AGenUI_AGenUI_FunctionCallResolution — companion result type in the dispatch system