Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
simple_workflow.cpp

Simple Workflow Example.

Simple Workflow Example

Version
0.1
Date
2025-07-20
#include <agents-cpp/agent_context.h>
#include <agents-cpp/config_loader.h>
#include <agents-cpp/llm_interface.h>
#include <agents-cpp/logger.h>
#include <agents-cpp/types.h>
#include <agents-cpp/workflows/prompt_chaining_workflow.h>
#include <string>
using namespace agents;
using namespace agents::workflows;
int main() {
// Initialize the logger
Logger::info("Simple Workflow Example");
Logger::info("This is a minimal example to demonstrate the agents-cpp library.");
Logger::info("It uses only the components that are actually implemented.");
// Check if we have any API keys configured
auto& config = ConfigLoader::getInstance();
bool hasOpenAI = config.has("OPENAI_API_KEY");
bool hasAnthropic = config.has("ANTHROPIC_API_KEY");
bool hasGoogle = config.has("GEMINI_API_KEY");
Logger::info("\nAPI Key Configuration Status:");
Logger::info("- OpenAI API Key: {}", hasOpenAI ? "Found ✓" : "Not found ✗");
Logger::info("- Anthropic API Key: {}", hasAnthropic ? "Found ✓" : "Not found ✗");
Logger::info("- Google API Key: {}", hasGoogle ? "Found ✓" : "Not found ✗");
if (hasOpenAI || hasAnthropic || hasGoogle) {
Logger::info("\nAPI keys found in configuration!");
Logger::info("You can now run examples without providing keys on the command line.");
} else {
Logger::warn("\nNo API keys found in configuration.");
Logger::warn("Please create a .env file or set environment variables.");
Logger::warn("See README.md for instructions.");
}
// Create agent context
auto context = std::make_shared<AgentContext>();
// Create the prompt chain workflow
PromptChainingWorkflow chain(context);
// The workflow needs an LLM to work, but we're not connecting to any external API
// This example just shows the structure and compilation
Logger::info("\nWorkflow created successfully.");
Logger::info("This example is just for demonstration purposes.");
Logger::info("To run a real workflow, you would need to:");
Logger::info("1. Set an LLM with an API key");
Logger::info("2. Add steps to the workflow");
Logger::info("3. Run the workflow with input");
return 0;
}
static ConfigLoader & getInstance()
Get the singleton instance of ConfigLoader.
static void init(Level level=Level::INFO)
Initialize the logger.
static void info(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at info level.
Definition logger.h:104
static void warn(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at warn level.
Definition logger.h:114
A workflow that chains multiple prompts together.
Definition prompt_chaining_workflow.h:26
@ INFO
Info logging level.
Definition logger.h:40
Worflows Namespace.
Definition workflow.h:22
Framework Namespace.
Definition agent.h:18