Skip to content

Commit 431d52b

Browse files
committed
Release 1.3.0
1 parent 9f5af4b commit 431d52b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1030
-680
lines changed

BUILD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
cc_import(
55
name = "python",
66
shared_library = select({
7-
"@platforms//os:macos": "lib/macos/libpython3.11.dylib",
87
"@platforms//os:linux": "lib/linux/libpython3.11.so",
8+
"@platforms//os:macos": "lib/macos/libpython3.11.dylib",
9+
"@platforms//os:windows": "lib/windows/libpython3.11.dll",
910
"//conditions:default": None,
1011
}),
1112
)
@@ -21,8 +22,9 @@ cc_import(
2122
"include",
2223
],
2324
shared_library = select({
24-
"@platforms//os:macos": "lib/macos/libagents_cpp_shared_lib.dylib",
2525
"@platforms//os:linux": "lib/linux/libagents_cpp_shared_lib.so",
26+
"@platforms//os:macos": "lib/macos/libagents_cpp_shared_lib.dylib",
27+
"@platforms//os:windows": "lib/windows/libagents_cpp_shared_lib.dll",
2628
"//conditions:default": None,
2729
}),
2830
deps = [

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
![Linux](https://img.shields.io/badge/Linux-FCC624?logo=linux&logoColor=black)
55
![macOS](https://img.shields.io/badge/macOS-000000?logo=apple&logoColor=F0F0F0)
6-
6+
![Windows](https://custom-icon-badges.demolab.com/badge/Windows-0078D6?logo=windows11&logoColor=white)
77

88
**Agents-SDK** is a **portable, high-performance C++ framework** for building **on-device, agentic AI systems** — think **LangChain for the edge**. This SDK is purpose-built for developers who want to create **local-first AI agents** that can reason, plan, and act without relying on the cloud.
99

@@ -85,7 +85,7 @@ You can configure API keys and other settings in three ways:
8585
```bash
8686
export OPENAI_API_KEY=your_api_key_here
8787
export ANTHROPIC_API_KEY=your_api_key_here
88-
export SERPAPI_KEY=your_api_key_here
88+
export WEBSEARCH_API_KEY=your_api_key_here
8989
```
9090

9191
3. Passing API keys as command-line arguments (not recommended for production):
@@ -129,7 +129,7 @@ int main() {
129129
JsonObject result = agent.run("Research the latest developments in quantum computing");
130130

131131
// Access the result
132-
std::cout << result["answer"].get<String>() << std::endl;
132+
std::cout << result["answer"].get<std::string>() << std::endl;
133133

134134
return 0;
135135
}
@@ -261,7 +261,7 @@ auto custom_tool = createTool(
261261
{"expression", "The expression to evaluate", "string", true}
262262
},
263263
[](const JsonObject& params) -> ToolResult {
264-
String expr = params["expression"];
264+
std::string expr = params["expression"];
265265
// Implement calculation logic here
266266
double result = evaluate(expr);
267267
return ToolResult{
@@ -285,7 +285,7 @@ public:
285285
CustomWorkflow(std::shared_ptr<Context> context)
286286
: Workflow(context) {}
287287
288-
JsonObject run(const String& input) override {
288+
JsonObject run(const std::string& input) override {
289289
// Implement your custom workflow logic here
290290
}
291291
};

examples/actor_agent_example.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace agents::workflows;
2121
ToolResult calculatorTool(const JsonObject& params) {
2222
try {
2323
if (params.contains("expression")) {
24-
String expr = params["expression"];
24+
std::string expr = params["expression"];
2525
// Very simple calculator for demo purposes
2626
// In a real-world scenario, you'd use a proper expression evaluator
2727
double result = 0.0;
@@ -51,7 +51,7 @@ ToolResult calculatorTool(const JsonObject& params) {
5151
} catch (const std::exception& e) {
5252
return {
5353
false,
54-
"Error calculating result: " + String(e.what()),
54+
"Error calculating result: " + std::string(e.what()),
5555
{{"error", e.what()}}
5656
};
5757
}
@@ -61,10 +61,10 @@ ToolResult calculatorTool(const JsonObject& params) {
6161
ToolResult weatherTool(const JsonObject& params) {
6262
try {
6363
if (params.contains("location")) {
64-
String location = params["location"];
64+
std::string location = params["location"];
6565

6666
// Just a dummy implementation for demo purposes
67-
String weather = "sunny";
67+
std::string weather = "sunny";
6868
double temperature = 22.0;
6969

7070
return {
@@ -86,7 +86,7 @@ ToolResult weatherTool(const JsonObject& params) {
8686
} catch (const std::exception& e) {
8787
return {
8888
false,
89-
"Error getting weather: " + String(e.what()),
89+
"Error getting weather: " + std::string(e.what()),
9090
{{"error", e.what()}}
9191
};
9292
}
@@ -97,7 +97,7 @@ int main(int argc, char* argv[]) {
9797
Logger::setLevel(Logger::Level::INFO);
9898

9999
// Get API key from .env, environment, or command line
100-
String api_key;
100+
std::string api_key;
101101
auto& config = ConfigLoader::getInstance();
102102

103103
// Try to get API key from config or environment
@@ -225,15 +225,15 @@ int main(int argc, char* argv[]) {
225225
agent->setOptions(agent_options);
226226

227227
// Register status callback
228-
agent->setStatusCallback([](const String& status) {
228+
agent->setStatusCallback([](const std::string& status) {
229229
Logger::info("Agent status: {}", status);
230230
});
231231

232232
// Initialize and run the agent
233233
agent->init();
234234

235235
// Run the agent with multiple tasks
236-
std::vector<String> tasks = {
236+
std::vector<std::string> tasks = {
237237
"What is 1+1?",
238238
"What's the weather like in New York?",
239239
"Tell me a short story about a robot learning to feel emotions."
@@ -253,4 +253,4 @@ int main(int argc, char* argv[]) {
253253
Logger::error("Error: {}", e.what());
254254
return EXIT_FAILURE;
255255
}
256-
}
256+
}

examples/autonomous_agent_example.cpp

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void detailedStepCallback(const AutonomousAgent::Step& step) {
3333
}
3434

3535
// Custom callback for human-in-the-loop
36-
bool detailedHumanApproval(const String& message, const JsonObject& context, String& modifications) {
36+
bool detailedHumanApproval(const std::string& message, const JsonObject& context, std::string& modifications) {
3737
if (!context.empty()) {
3838
Logger::info("\nContext Information:");
3939
Logger::info("{}", context.dump(2));
@@ -48,7 +48,7 @@ bool detailedHumanApproval(const String& message, const JsonObject& context, Str
4848

4949
if (response == 'm' || response == 'M') {
5050
Logger::info("Enter your modifications or instructions: ");
51-
String user_modifications;
51+
std::string user_modifications;
5252
std::getline(std::cin, user_modifications);
5353

5454
// Set modifications output parameter
@@ -79,33 +79,20 @@ int main() {
7979
auto& config = ConfigLoader::getInstance();
8080

8181
// Proceed based on provider choice and API key in the environment
82-
if (provider_choice == 1) {
83-
bool hasOpenAI = config.has("OPENAI_API_KEY");
84-
if (hasOpenAI) {
85-
llm = createLLM("openai", config.get("OPENAI_API_KEY"), "gpt-4o-2024-05-13");
82+
try {
83+
if (provider_choice == 1) {
84+
llm = createLLM("openai", config.get("OPENAI_API_KEY"), "gpt-4o");
85+
} else if (provider_choice == 2) {
86+
llm = createLLM("anthropic", config.get("ANTHROPIC_API_KEY"), "claude-sonnet-4-5");
87+
} else if (provider_choice == 3) {
88+
llm = createLLM("google", config.get("GEMINI_API_KEY"), "gemini-2.5-flash");
8689
} else {
87-
Logger::error("OPENAI_API_KEY not found in environment.");
90+
Logger::error("Invalid provider choice.");
8891
return EXIT_FAILURE;
8992
}
90-
} else if (provider_choice == 2) {
91-
// Note: This assumes the user has the Anthropic API key in the environment
92-
bool hasAnthropic = config.has("ANTHROPIC_API_KEY");
93-
if (hasAnthropic) {
94-
llm = createLLM("anthropic", config.get("ANTHROPIC_API_KEY"), "claude-3-5-sonnet-20240620");
95-
} else {
96-
Logger::error("ANTHROPIC_API_KEY not found in environment.");
97-
return EXIT_FAILURE;
98-
}
99-
} else if (provider_choice == 3) {
100-
bool hasGoogle = config.has("GEMINI_API_KEY");
101-
if (hasGoogle) {
102-
llm = createLLM("google", config.get("GEMINI_API_KEY"), "gemini-2.0-flash");
103-
} else {
104-
Logger::error("GEMINI_API_KEY not found in environment.");
105-
return EXIT_FAILURE;
106-
}
107-
} else {
108-
Logger::error("Invalid provider choice.");
93+
} catch (const std::exception& e) {
94+
Logger::error("Error creating LLM: {}", e.what());
95+
Logger::error("Please ensure the appropriate API key is set in the environment.");
10996
return EXIT_FAILURE;
11097
}
11198

@@ -121,17 +108,15 @@ int main() {
121108

122109
// Set system prompt for the context
123110
context->setSystemPrompt(
124-
"You are a helpful, autonomous assistant with access to tools."
125-
"You can use these tools to accomplish tasks for the user."
111+
"You are a helpful, autonomous assistant with access to tools. "
112+
"You can use these tools to accomplish tasks for the user. "
126113
"Think step by step and be thorough in your approach."
127114
);
128115

129-
// Register tools
130-
context->registerTool(tools::createWebSearchTool());
131-
context->registerTool(tools::createWikipediaTool());
132-
// Uncomment when tools are implemented
133-
// context->registerTool(tools::createWeatherTool());
134-
// context->registerTool(tools::createCalculatorTool());
116+
// Register tools from tool registry
117+
auto registry = tools::ToolRegistry::global();
118+
tools::registerStandardTools(registry, llm);
119+
context->registerToolRegistry(registry);
135120

136121
// Create a custom tool
137122
auto summarize_tool = createTool(
@@ -142,7 +127,7 @@ int main() {
142127
{"max_length", "Maximum length of summary in words", "integer", false}
143128
},
144129
[context](const JsonObject& params) -> ToolResult {
145-
String text = params["text"];
130+
std::string text = params["text"];
146131
int max_length = params.contains("max_length") ? params["max_length"].get<int>() : 100;
147132

148133
// Create a specific context for summarization
@@ -152,11 +137,11 @@ int main() {
152137
"that capture the main points of the provided text."
153138
);
154139

155-
String prompt = "Summarize the following text in no more than " +
140+
std::string prompt = "Summarize the following text in no more than " +
156141
std::to_string(max_length) + " words:\n\n" + text;
157142

158143
LLMResponse llm_response = summary_context->getLLM()->chat(prompt);
159-
String summary = llm_response.content;
144+
std::string summary = llm_response.content;
160145

161146
return ToolResult{
162147
true,
@@ -182,12 +167,15 @@ int main() {
182167
// Set planning strategy based on user choice
183168
AutonomousAgent::PlanningStrategy strategy;
184169
switch (strategy_choice) {
170+
case 1:
171+
strategy = AutonomousAgent::PlanningStrategy::REACT;
172+
break;
185173
case 2:
186174
strategy = AutonomousAgent::PlanningStrategy::PLAN_AND_EXECUTE;
187175
break;
188-
case 1:
189176
default:
190-
strategy = AutonomousAgent::PlanningStrategy::REACT;
177+
Logger::error("Invalid strategy choice.");
178+
return EXIT_FAILURE;
191179
}
192180
agent.setPlanningStrategy(strategy);
193181

@@ -228,7 +216,7 @@ int main() {
228216
Logger::info("==================================================");
229217
Logger::info("Enter a question or task for the agent (or 'exit' to quit):");
230218

231-
String user_input;
219+
std::string user_input;
232220
while (true) {
233221
Logger::info("\n> ");
234222
std::getline(std::cin, user_input);
@@ -256,7 +244,7 @@ int main() {
256244
Logger::info("\n==================================================");
257245
Logger::info(" FINAL RESULT ");
258246
Logger::info("==================================================");
259-
Logger::info("{}", result["answer"].get<String>());
247+
Logger::info("{}", result["answer"].get<std::string>());
260248

261249
// Display completion statistics
262250
Logger::info("\n--------------------------------------------------");
@@ -274,4 +262,4 @@ int main() {
274262
}
275263

276264
return EXIT_SUCCESS;
277-
}
265+
}

0 commit comments

Comments
 (0)