enables deep research
This commit is contained in:

committed by
Geoff Seemueller

parent
805b524471
commit
2e45c6b67b
32
src/agents/deep_research.rs
Normal file
32
src/agents/deep_research.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use crate::utils::utils::run_agent;
|
||||
use tokio::process::Child;
|
||||
use tracing;
|
||||
|
||||
pub async fn agent(stream_id: &str, input: &str) -> Result<Child, String> {
|
||||
run_agent(stream_id, input, "./packages/genaiscript/genaisrc/deep-research.genai.mts", 60).await
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::agents::deep_research::agent;
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_deepresearch() {
|
||||
// a really provocative question for research that generally yields infinite complexity with each run
|
||||
let input = "What is a life of meaning?";
|
||||
|
||||
let mut command = agent("test-deepresearch-agent", input).await.unwrap();
|
||||
|
||||
// let mut stdout = String::new();
|
||||
|
||||
// command.stdout.take().unwrap().read_to_string(&mut stdout).await.unwrap();
|
||||
|
||||
// println!("stdout: {}", stdout);
|
||||
// // Optionally, you can capture and inspect stdout if needed:
|
||||
let _output = command.wait_with_output().await.expect("Failed to wait for output");
|
||||
// println!("Stdout: {}", String::from_utf8_lossy(&output.stdout));
|
||||
// println!("Stderr: {}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
pub(crate) mod news;
|
||||
pub(crate) mod scrape;
|
||||
pub(crate) mod search;
|
||||
pub(crate) mod image_generator;
|
||||
pub(crate) mod image_generator;
|
||||
pub(crate) mod deep_research;
|
@@ -97,6 +97,9 @@ pub async fn use_agent(Path(agent_id): Path<String>) -> impl IntoResponse {
|
||||
"image-generator" => {
|
||||
crate::agents::image_generator::agent(agent_id.as_str(), &*input).await
|
||||
}
|
||||
"deep-research" => {
|
||||
crate::agents::deep_research::agent(agent_id.as_str(), &*input).await
|
||||
}
|
||||
"web-scrape" => crate::agents::scrape::agent(agent_id.as_str(), &*input).await,
|
||||
_ => {
|
||||
tracing::error!("Unsupported resource type: {}", resource);
|
||||
|
@@ -18,6 +18,7 @@ pub fn create_router() -> Router {
|
||||
.make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
|
||||
.on_response(trace::DefaultOnResponse::new().level(Level::INFO)),
|
||||
)
|
||||
.layer(tower_http::cors::CorsLayer::very_permissive())
|
||||
.fallback(handle_not_found)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user