Expand description
§Spider Agent
A concurrent-safe multimodal agent for web automation and research.
§Features
- Concurrent-safe: Designed to be wrapped in
Arcfor multi-task access - Feature-gated: Only include dependencies you need
- Multiple LLM providers: OpenAI, OpenAI-compatible APIs
- Multiple search providers: Serper, Brave, Bing, Tavily
- Browser automation: Chrome support via chromiumoxide
§Quick Start
ⓘ
use spider_agent::{Agent, AgentConfig};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let agent = Arc::new(Agent::builder()
.with_openai("sk-...", "gpt-4o-mini")
.with_search_serper("serper-key")
.build()?);
// Search
let results = agent.search("rust web frameworks").await?;
println!("Found {} results", results.len());
// Extract from first result
let html = agent.fetch(&results.results[0].url).await?.html;
let data = agent.extract(&html, "Extract framework name and features").await?;
println!("{}", serde_json::to_string_pretty(&data)?);
Ok(())
}§Concurrent Execution
ⓘ
use spider_agent::Agent;
use std::sync::Arc;
let agent = Arc::new(Agent::builder()
.with_openai("sk-...", "gpt-4o")
.with_search_serper("serper-key")
.with_max_concurrent_llm_calls(10)
.build()?);
// Execute multiple searches concurrently
let queries = vec!["rust async", "rust web frameworks", "rust databases"];
let mut handles = Vec::new();
for query in queries {
let agent = agent.clone();
let query = query.to_string();
handles.push(tokio::spawn(async move {
agent.search(&query).await
}));
}
// Collect results
for handle in handles {
let result = handle.await??;
println!("Found {} results", result.results.len());
}§Feature Flags
openai- OpenAI/OpenAI-compatible LLM providerchrome- Browser automation via chromiumoxidesearch- Base search functionalitysearch_serper- Serper.dev search providersearch_brave- Brave Search providersearch_bing- Bing Search providersearch_tavily- Tavily AI Search providerfull- All features
Re-exports§
pub use automation::ActionRecord;pub use automation::ActionResult;pub use automation::ActionType;pub use automation::AutomationConfig;pub use automation::AutomationResult;pub use automation::AutomationUsage;pub use automation::CaptureProfile;pub use automation::ChainBuilder;pub use automation::ChainCondition;pub use automation::ChainContext;pub use automation::ChainResult;pub use automation::ChainStep;pub use automation::ChainStepResult;pub use automation::CleaningIntent;pub use automation::ContentAnalysis;pub use automation::CostTier;pub use automation::ExtractionSchema;pub use automation::FormField;pub use automation::FormInfo;pub use automation::HtmlCleaningProfile;pub use automation::InteractiveElement;pub use automation::ModelPolicy;pub use automation::PageObservation;pub use automation::RecoveryStrategy;pub use automation::RetryPolicy;pub use automation::SelectorCache;pub use automation::SelectorCacheEntry;pub use automation::StructuredOutputConfig;pub use automation::cache::CacheStats;pub use automation::cache::CacheValue;pub use automation::cache::SmartCache;pub use automation::executor::BatchExecutor;pub use automation::executor::ChainExecutor;pub use automation::executor::PrefetchManager;pub use automation::router::ModelRouter;pub use automation::router::RoutingDecision;pub use automation::router::TaskAnalysis;pub use automation::router::TaskCategory;
Modules§
- automation
- Automation module for spider_agent.
Structs§
- Agent
- Multimodal agent for web automation and research.
- Agent
Builder - Agent builder for configuring and creating agents.
- Agent
Config - Agent configuration.
- Agent
Memory - Session memory for storing state across operations.
- Completion
Options - Options for completion requests.
- Completion
Response - Response from a completion request.
- Fetch
Result - Result from fetching a URL.
- Message
- A message in a conversation.
- Page
Extraction - Extraction from a single page.
- Research
Options - Research options for research tasks.
- Retry
Config - Retry configuration.
- Search
Options - Search options for web search.
- Token
Usage - Token usage from a completion.
- Usage
Snapshot - Snapshot of usage statistics.
- Usage
Stats - Usage statistics for tracking agent operations.
Enums§
- Agent
Error - Agent error types.
- Html
Cleaning Mode - HTML cleaning mode.
- Message
Content - Message content - either text or multi-part.
- Search
Error - Search-specific error types.
- Time
Range - Time range for filtering search results.
Traits§
- LLMProvider
- LLM provider trait for abstracting different LLM APIs.
Type Aliases§
- Agent
Result - Result type for agent operations.