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

@@ -72,7 +72,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
}
```
@@ -82,20 +82,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` 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 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();