Skip to content

Commit

Permalink
chore: improve anda_bot
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Feb 21, 2025
1 parent 24be033 commit 6b19843
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agents/anda_bot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "anda_bot"
description = "I'm Anda ICP, Digital panda 🐼 by Anda framework. Secured in TEE, memories on ICP chain.✨"
repository = "https://github.com/ldclabs/anda/tree/main/agents/anda_bot"
publish = false
version = "0.4.1"
version = "0.4.2"
edition.workspace = true
keywords.workspace = true
categories.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion agents/anda_bot/nitro_enclave/amd64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN chmod +x ic_tee_daemon
RUN wget -O ic_tee_nitro_gateway https://github.com/ldclabs/ic-tee/releases/download/v0.3.0/ic_tee_nitro_gateway
RUN chmod +x ic_tee_nitro_gateway

RUN wget -O anda_bot https://github.com/ldclabs/anda/releases/download/v0.4.1/anda_bot
RUN wget -O anda_bot https://github.com/ldclabs/anda/releases/download/v0.4.2/anda_bot
RUN chmod +x anda_bot

FROM debian:bookworm-slim AS runtime
Expand Down
22 changes: 16 additions & 6 deletions agents/anda_bot/src/twitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,13 @@ impl TwitterDaemon {
if res.failed_reason.is_none() {
// Reply to the original tweet
let tweet: Option<&str> = tweet.id.as_deref();
let _ = self.scraper.send_tweet(&res.content, tweet, None).await?;
let content = remove_quotes(res.content);
let _ = self.scraper.send_tweet(&content, tweet, None).await?;

log::info!(
tweet_user = tweet_user,
tweet_id = tweet_id,
chars = res.content.chars().count(),
chars = content.chars().count(),
time_elapsed = ctx.time_elapsed().as_millis() as u64;
"handle mention");
}
Expand Down Expand Up @@ -378,7 +379,7 @@ impl TwitterDaemon {
.character
.to_request(
"\
Reply the tweet with a single clear, natural sentence.\
Reply the tweet with a single clear, natural sentence. No hashtags.\
"
.to_string(),
ctx.user(),
Expand All @@ -395,7 +396,7 @@ impl TwitterDaemon {
None => {
let _ = self
.scraper
.send_tweet(&res.content, Some(tweet_id), None)
.send_tweet(&remove_quotes(res.content), Some(tweet_id), None)
.await?;
return Ok(true);
}
Expand All @@ -416,7 +417,7 @@ impl TwitterDaemon {
.character
.to_request(
"\
Reply the tweet with a single clear, natural sentence.\
Quote the tweet with a single clear, natural sentence. No hashtags.\
"
.to_string(),
ctx.user(),
Expand All @@ -433,7 +434,7 @@ impl TwitterDaemon {
None => {
let _ = self
.scraper
.send_quote_tweet(&res.content, tweet_id, None)
.send_quote_tweet(&remove_quotes(res.content), tweet_id, None)
.await?;
return Ok(true);
}
Expand Down Expand Up @@ -510,3 +511,12 @@ mod tests {
// std::fs::write("home_timeline_tweets.json", tweets).unwrap();
}
}

fn remove_quotes(s: String) -> String {
let mut chars = s.chars();
if chars.next() == Some('"') && chars.next_back() == Some('"') {
chars.collect()
} else {
s
}
}
2 changes: 1 addition & 1 deletion anda_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "anda_engine"
description = "Agents engine for Anda -- an AI agent framework built with Rust, powered by ICP and TEEs."
repository = "https://github.com/ldclabs/anda/tree/main/anda_engine"
publish = true
version = "0.4.4"
version = "0.4.5"
edition.workspace = true
keywords.workspace = true
categories.workspace = true
Expand Down

0 comments on commit 6b19843

Please sign in to comment.