update docs

This commit is contained in:
geoffsee
2025-05-27 15:18:11 -04:00
parent 2c46e7b2fc
commit 2af47e476a
5 changed files with 18 additions and 33 deletions

View File

@@ -13,7 +13,6 @@ The following agents are currently available:
| Web Search | Performs web searches using SearxNG | `web-search` |
| News Search | Searches for news articles | `news-search` |
| Image Generator | Generates images based on text prompts | `image-generator` |
| Finance Query | Provides financial information | `finance-query` |
| Web Scrape | Scrapes content from web pages | `web-scrape` |
## Creating a New Agent
@@ -55,7 +54,7 @@ use tracing;
use crate::utils::utils::run_agent;
pub async fn your_agent_name(stream_id: &str, input: &str) -> Result<Child, String> {
pub async fn agent(stream_id: &str, input: &str) -> Result<Child, String> {
run_agent(stream_id, input, "./packages/genaiscript/genaisrc/your-agent.genai.mts").await
}
```
@@ -65,20 +64,20 @@ pub async fn your_agent_name(stream_id: &str, input: &str) -> Result<Child, Stri
Add your agent to the `src/agents/mod.rs` file:
```rust
pub mod your_agent_name;
pub(crate) mod your_module;
```
### 4. Register the Agent in the Webhook Handler
Add your agent to the match statement in the `handle_webhooks_post` function in `src/handlers/webhooks.rs`:
Add your agent to the match statement in the `use_agent` function in `src/handlers/agents.rs`:
```
// In the handle_webhooks_post function
// In the use_agent function
let cmd = match resource.as_str() {
"web-search" => search_agent(stream_id.as_str(), &*input).await,
"news-search" => news_agent(stream_id.as_str(), &*input).await,
"web-search" => crate::agents::search::agent(agent_id.as_str(), &*input).await,
"news-search" => crate::agents::news::agent(agent_id.as_str(), &*input).await,
// Add your agent here
"your-resource-name" => your_agent_name(stream_id.as_str(), &*input).await,
"your-resource-name" => crate::agents::your_module::agent(agent_id.as_str(), &*input).await,
_ => {
tracing::error!("Unsupported resource type: {}", resource);
return StatusCode::BAD_REQUEST.into_response();

View File

@@ -44,7 +44,7 @@ Creates a new stream resource for an agent.
| Field | Type | Description |
|-------|------|-------------|
| `resource` | string | The type of agent to use (e.g., "web-search", "news-search", "image-generator", "finance-query", "web-scrape") |
| `resource` | string | The type of agent to use (e.g., "web-search", "news-search", "image-generator", "web-scrape") |
| `input` | string | The input query or prompt for the agent |
**Response:**
@@ -81,7 +81,6 @@ The following agent types are available for use with the `resource` field in the
| `web-search` | Performs web searches using SearxNG |
| `news-search` | Searches for news articles |
| `image-generator` | Generates images based on text prompts |
| `finance-query` | Provides financial information |
| `web-scrape` | Scrapes content from web pages |
## Error Responses
@@ -109,4 +108,4 @@ curl -X POST https://your-server.com/api/webhooks \
```bash
curl https://your-server.com/webhooks/abc123 \
-H "Authorization: Bearer <session_token>"
```
```

View File

@@ -12,7 +12,7 @@ Welcome to the documentation for web-agent-rs, a GenAIScript host for integratio
## Overview
web-agent-rs is a server that hosts GenAIScript agents for integration into conversational AI applications. It provides a simple API for creating and consuming stream resources that execute various agents to perform tasks like web search, news search, image generation, finance queries, and web scraping.
web-agent-rs is a server that hosts GenAIScript agents for integration into conversational AI applications. It provides a simple API for creating and consuming stream resources that execute various agents to perform tasks like web search, news search, image generation, and web scraping.
## Architecture
@@ -42,4 +42,4 @@ Please note that this project has not undergone a formal security assessment. Yo
## Contributing
Contributions to web-agent-rs are welcome! Please feel free to submit issues and pull requests to improve the project.
Contributions to web-agent-rs are welcome! Please feel free to submit issues and pull requests to improve the project.

View File

@@ -128,23 +128,10 @@ genaiscript run packages/genaiscript/genaisrc/web-scrape.genai.mts --vars USER_I
genaiscript run packages/genaiscript/genaisrc/web-scrape.genai.mts --vars USER_INPUT='{"url":"https://www.time4learning.com/homeschool-curriculum/high-school/eleventh-grade/math.html","query":"What is on this page?", "action": "scrape"}'
```
#### Finance Query Agent
```bash
# Crypto quote
genaiscript run packages/genaiscript/genaisrc/finance-query.genai.mts --vars USER_INPUT='Get a quote for BTC'
# Crypto news
genaiscript run packages/genaiscript/genaisrc/finance-query.genai.mts --vars USER_INPUT='What is the news for Bitcoin?'
# Market overview
genaiscript run packages/genaiscript/genaisrc/finance-query.genai.mts --vars USER_INPUT='What are the trending symbols in the market?'
```
Note the different input formats:
- Simple text queries for search and news agents
- JSON objects for the web scrape agent, specifying URL, query, and action
- Specific command-like queries for the finance agent
## Related Documentation