1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// show feature flags in the generated documentation
// https://doc.rust-lang.org/rustdoc/unstable-features.html#extensions-to-the-doc-attribute
//! Swiftide agents are a flexible way to build fast and reliable AI agents.
//!
//! # Features
//!
//! * **Tools**: Tools can be defined as functions using the `#[tool]` attribute macro, the `Tool`
//! derive macro, or manually implementing the `Tool` trait.
//! * **Hooks**: At various stages of the agent lifecycle, hooks can be defined to run custom logic.
//! These are defined when building the agent, and each take a closure.
//! * **Context**: Agents operate in an `AgentContext`, which is a shared state between tools and
//! hooks. The context is responsible for managing the completions and interacting with the
//! outside world.
//! * **Tool Execution**: A context takes a tool executor (local by default) to execute its tools
//! on. This enables tools to be run i.e. in containers, remote, etc.
//! * **System prompts**: The agent builder accepts anything that converts into a `Prompt`,
//! including strings.
//! * **Open Telemetry**: Agents are fully instrumented with open telemetry.
//!
//! # Example
//!
//! ```ignore
//! # use swiftide_agents::Agent;
//! # use swiftide_integrations as integrations;
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let openai = integrations::openai::OpenAI::builder()
//! .default_prompt_model("gpt-4o-mini")
//! .build()?;
//!
//! Agent::builder()
//! .llm(&openai)
//! .before_completion(move |_,_|
//! Box::pin(async move {
//! println!("Before each tool");
//! Ok(())
//! })
//! )
//! .build()?
//! .query("What is the meaning of life?")
//! .await?;
//! # return Ok(());
//!
//! # }
//! ```
//!
//! Agents run in a loop as long as they have new messages to process.
pub use ;
pub use DefaultContext;
pub use ;
pub use TaskAgent;