Lux.Agent.Loaders (Lux v0.5.0)
View SourceEntry point for loading agent configurations from various sources.
Summary
Functions
Creates agent module(s) from JSON configuration(s). The source can be
Functions
Creates agent module(s) from JSON configuration(s). The source can be:
- A JSON string:
~s({"id": "researcher", ...})
- A file path:
"agents/researcher.json"
- A directory path:
"agents/"
(loads all .json files) - A list of file paths:
["agents/researcher.json", "agents/writer.json"]
Returns:
{:ok, [module()]}
for successful loads (always returns a list){:error, term()}
on failure
Examples
# Load from file
{:ok, [ResearchAgent]} = Loaders.from_json("agents/researcher.json")
# Load from directory
{:ok, [ResearchAgent, WriterAgent]} = Loaders.from_json("agents/")
# Load from JSON string
json = ~s({
"id": "researcher",
"name": "Research Agent",
"description": "Conducts research",
"goal": "Research effectively",
"module": "ResearchAgent"
})
{:ok, [ResearchAgent]} = Loaders.from_json(json)
# Load multiple files
{:ok, [Agent1, Agent2]} = Loaders.from_json(["agent1.json", "agent2.json"])