Skip to content

Commit

Permalink
docs(agents): Fix toplevel agent docs not showing up in rustdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
timonv committed Dec 19, 2024
1 parent 5d2ced3 commit a4490f3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 44 deletions.
78 changes: 38 additions & 40 deletions swiftide-agents/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
/*!
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 prompt defaults**: `SystemPrompt` provides a default, customizable prompt for the agent. If you want to provider your own prompt, the builder takes anything that converts into a `Prompt`, including strings.
* **Open Telemetry**: Agents are fully instrumented with open telemetry.
# Example
```no_run
# 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.
*/
//! 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 prompt defaults**: `SystemPrompt` provides a default, customizable prompt for the agent. If you want to provider your own prompt, the builder takes anything that converts into a `Prompt`, including strings.
//! * **Open Telemetry**: Agents are fully instrumented with open telemetry.
//!
//! # Example
//!
//! ```no_run
//! # 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.
mod agent;
mod default_context;
pub mod hooks;
Expand Down
7 changes: 3 additions & 4 deletions swiftide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ pub use swiftide_core::prompt;
pub use swiftide_core::type_aliases::*;

#[cfg(feature = "swiftide-agents")]
pub mod agents {
#[doc(inline)]
pub use swiftide_agents::*;
}
#[doc(inline)]
pub use swiftide_agents as agents;

/// Common traits for common behaviour, re-exported from indexing and query
pub mod traits {
#[doc(inline)]
Expand Down

0 comments on commit a4490f3

Please sign in to comment.