@@ -224,9 +224,7 @@ export default {
224224 case 'message' : {
225225 await bot . sendTyping ( ) ;
226226 const prompt = bot . update . message ?. text ?. toString ( ) ?? '' ;
227- const { results } = await env . DB . prepare ( 'SELECT * FROM Messages WHERE userId=?' )
228- . bind ( bot . update . inline_query ? bot . update . inline_query . from . id : bot . update . message ?. from . id )
229- . all ( ) ;
227+ const { results } = await env . DB . prepare ( 'SELECT * FROM Messages WHERE userId=?' ) . bind ( bot . update . message ?. from . id ) . all ( ) ;
230228 const message_history = results . map ( ( col ) => ( { role : 'system' , content : col . content as string } ) ) ;
231229 const messages = [
232230 { role : 'system' , content : 'You are a friendly assistant named TuxRobot. Use lots of emojis in your responses.' } ,
@@ -249,11 +247,7 @@ export default {
249247 if ( response . response ) {
250248 await bot . reply ( await markdown_to_html ( response . response ?? '' ) , 'HTML' ) ;
251249 await env . DB . prepare ( 'INSERT INTO Messages (id, userId, content) VALUES (?, ?, ?)' )
252- . bind (
253- crypto . randomUUID ( ) ,
254- bot . update . inline_query ? bot . update . inline_query . from . id : bot . update . message ?. from . id ,
255- `'[INST] ${ prompt } [/INST] \n ${ response . response } ` ,
256- )
250+ . bind ( crypto . randomUUID ( ) , bot . update . message ?. from . id , `'[INST] ${ prompt } [/INST] \n ${ response . response } ` )
257251 . run ( ) ;
258252 }
259253 }
@@ -286,13 +280,7 @@ export default {
286280 const prompt = bot . update . business_message ?. text ?. toString ( ) ?? '' ;
287281 if ( bot . update . business_message ?. from . id !== 69148517 ) {
288282 const { results } = await env . DB . prepare ( 'SELECT * FROM Messages WHERE userId=?' )
289- . bind (
290- bot . update . inline_query
291- ? bot . update . inline_query . from . id
292- : bot . update . business_message
293- ? bot . update . business_message . from . id
294- : bot . update . message ?. from . id ,
295- )
283+ . bind ( bot . update . business_message ?. from . id )
296284 . all ( ) ;
297285 const message_history = results . map ( ( col ) => ( { role : 'system' , content : col . content as string } ) ) ;
298286 const messages = [
@@ -320,15 +308,7 @@ export default {
320308 if ( response . response ) {
321309 await bot . reply ( await markdown_to_html ( response . response ?? '' ) , 'HTML' ) ;
322310 await env . DB . prepare ( 'INSERT INTO Messages (id, userId, content) VALUES (?, ?, ?)' )
323- . bind (
324- crypto . randomUUID ( ) ,
325- bot . update . inline_query
326- ? bot . update . inline_query . from . id
327- : bot . update . business_message
328- ? bot . update . business_message . from . id
329- : bot . update . message ?. from . id ,
330- `'[INST] ${ prompt } [/INST] \n ${ response . response } ` ,
331- )
311+ . bind ( crypto . randomUUID ( ) , bot . update . business_message ?. from . id , `'[INST] ${ prompt } [/INST] \n ${ response . response } ` )
332312 . run ( ) ;
333313 }
334314 }
0 commit comments