Skip to content

Commit d3cf300

Browse files
committed
fix
1 parent 97238f2 commit d3cf300

File tree

1 file changed

+6
-43
lines changed

1 file changed

+6
-43
lines changed

src/ai_message.rs

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl Tool for SocialCredit {
8181
logger.push(format!("{}: {}", action, args.social_credit.abs()));
8282
}
8383

84-
let mut user = {
84+
let mut user = match {
8585
let db = self.0.get()?;
8686
let mut stm = db
8787
.prepare("SELECT * FROM user WHERE id = ?")
@@ -90,7 +90,9 @@ impl Tool for SocialCredit {
9090
from_row::<User>(row).map_err(|_| rusqlite::Error::QueryReturnedNoRows)
9191
})
9292
.map_err(|err| color_eyre::eyre::eyre!("Failed to query SQL query: {:?}", err))
93-
.unwrap()
93+
} {
94+
Ok(v) => v,
95+
_ => return Ok(0),
9496
};
9597

9698
if args.remove == Some(true) && args.social_credit > 0 {
@@ -100,29 +102,11 @@ impl Tool for SocialCredit {
100102
user.social_credit += args.social_credit;
101103
user.update_sync(&*self.0.get()?)
102104
.map_err(|err| color_eyre::eyre::eyre!("Failed to update SQL query: {:?}", err))
103-
.unwrap();
105+
.ok();
104106
Ok(user.social_credit)
105107
}
106108
}
107109

108-
#[derive(Deserialize, Serialize, Debug)]
109-
struct CrossUserMemoryArgs {
110-
user_name: String,
111-
memory_name: String,
112-
memory_content: String,
113-
}
114-
115-
#[derive(Deserialize, Serialize, Debug)]
116-
struct CrossUserMemoryRemoveArgs {
117-
user_name: String,
118-
memory_name: String,
119-
}
120-
121-
#[derive(Deserialize, Serialize, Debug)]
122-
struct BraveSearchArgs {
123-
pub query: String,
124-
}
125-
126110
pub async fn main(
127111
database: r2d2::Pool<SqliteConnectionManager>,
128112
user_id: u64,
@@ -165,23 +149,6 @@ pub async fn main(
165149
// Create tool call logger
166150
let tool_call_logger = Arc::new(Mutex::new(Vec::new()));
167151

168-
// Extract user mentions from context to build a name->id mapping
169-
let mut user_mentions = HashMap::new();
170-
for line in context.lines() {
171-
if let Some(colon_pos) = line.find(':') {
172-
let username = line[..colon_pos].trim();
173-
if !username.is_empty() && username != "The Trickster" {
174-
// We'll use hash-based IDs for users we see in context
175-
// In a real implementation, you'd want to resolve these properly
176-
use std::collections::hash_map::DefaultHasher;
177-
use std::hash::{Hash, Hasher};
178-
let mut hasher = DefaultHasher::new();
179-
username.hash(&mut hasher);
180-
user_mentions.insert(username.to_string(), hasher.finish());
181-
}
182-
}
183-
}
184-
185152
// Create agent with tools that log their usage
186153
let smart_agent = openai_client
187154
.agent("gpt-5-mini")
@@ -194,11 +161,7 @@ message context:
194161
.tool(SocialCredit(database.clone(), user_id, tool_call_logger.clone()))
195162
.build();
196163

197-
// Allow multiple tool calls by using multi-turn
198-
let response = smart_agent
199-
.prompt(message)
200-
.multi_turn(3) // Allow up to 5 tool calling turns
201-
.await?;
164+
let response = smart_agent.prompt(message).await?;
202165

203166
// Extract logged tool calls
204167
let tool_calls = if let Ok(logger) = tool_call_logger.lock() {

0 commit comments

Comments
 (0)