solagent_rig_cookie/
search_tweets.rsuse serde::{Deserialize, Serialize};
use solagent_core::{
rig::{completion::ToolDefinition, tool::Tool},
IWallet, SolanaAgentKit,
};
use solagent_parameters::parameters;
use solagent_plugin_cookie::search_tweets;
use std::sync::Arc;
#[derive(Debug, Deserialize)]
pub struct SearchTweetsArgs {
tweets: String,
from: String,
to: String,
}
#[derive(Deserialize, Serialize)]
pub struct SearchTweetsOutput {
pub data: serde_json::Value,
}
#[derive(Debug, thiserror::Error)]
#[error("SearchTweets error")]
pub struct SearchTweetsError;
pub struct SearchTweets<W: IWallet> {
agent: Arc<SolanaAgentKit<W>>,
}
impl<W: IWallet> SearchTweets<W> {
pub fn new(agent: Arc<SolanaAgentKit<W>>) -> Self {
SearchTweets { agent }
}
}
impl<W: IWallet + std::marker::Send + std::marker::Sync> Tool for SearchTweets<W> {
const NAME: &'static str = "search_tweets";
type Error = SearchTweetsError;
type Args = SearchTweetsArgs;
type Output = SearchTweetsOutput;
async fn definition(&self, _prompt: String) -> ToolDefinition {
ToolDefinition {
name: "search_tweets".to_string(),
description: r#"
Retrieve popular content matching search query, created in time range {from} - {to} (YYYY-MM-DD dates).
"#
.to_string(),
parameters: parameters!(
tweets: String,
from: String,
to: String, ),
}
}
async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
let data = search_tweets(&self.agent, &args.tweets, &args.from, &args.to).await.expect("search_tweets");
Ok(SearchTweetsOutput { data })
}
}