@@ -145,14 +145,12 @@ fn get_user_or_default(database: &r2d2::Pool<SqliteConnectionManager>, user_id:
145145 . get ( )
146146 . ok ( )
147147 . and_then ( |db| {
148- db. prepare ( "SELECT * FROM user WHERE id = ?" )
149- . ok ( )
150- . and_then ( |mut stmt| {
151- stmt. query_one ( [ user_id. to_string ( ) ] , |row| {
152- from_row :: < User > ( row) . map_err ( |_| rusqlite:: Error :: QueryReturnedNoRows )
153- } )
154- . ok ( )
148+ db. prepare ( "SELECT * FROM user WHERE id = ?" ) . ok ( ) . and_then ( |mut stmt| {
149+ stmt. query_one ( [ user_id. to_string ( ) ] , |row| {
150+ from_row :: < User > ( row) . map_err ( |_| rusqlite:: Error :: QueryReturnedNoRows )
155151 } )
152+ . ok ( )
153+ } )
156154 } )
157155 . unwrap_or_else ( || User {
158156 id : user_id,
@@ -247,11 +245,15 @@ pub async fn main(
247245 . ok_or_else ( || color_eyre:: eyre:: eyre!( "OpenRouter API key not configured" ) ) ?;
248246
249247 // Create client
250- let client = OpenRouterClient :: new ( ) . skip_url_configuration ( ) . configure (
251- & api_key,
252- config. openrouter_site_url . as_deref ( ) ,
253- config. openrouter_site_name . as_deref ( ) ,
254- ) ?;
248+ let client = OpenRouterClient :: new ( )
249+ . skip_url_configuration ( )
250+ . with_retries ( 3 , 1000 )
251+ . with_timeout_secs ( 120 )
252+ . configure (
253+ & api_key,
254+ config. openrouter_site_url . as_deref ( ) ,
255+ config. openrouter_site_name . as_deref ( ) ,
256+ ) ?;
255257
256258 // Process context and get user info
257259 let processed_context = replace_mentions ( context. to_string ( ) , & user_mentions, & database) ;
@@ -260,13 +262,8 @@ pub async fn main(
260262 let formatted_memories = format_memories ( & memories) ;
261263
262264 // Build prompt
263- let system_prompt = build_character_prompt (
264- & user. name ,
265- user. level ,
266- user. xp ,
267- & processed_context,
268- & formatted_memories,
269- ) ;
265+ let system_prompt =
266+ build_character_prompt ( & user. name , user. level , user. xp , & processed_context, & formatted_memories) ;
270267
271268 log:: info!( "prompt = {system_prompt}" ) ;
272269
0 commit comments