1
1
import { Message } from "@telegraf/types" ;
2
2
import { Context , Telegraf } from "telegraf" ;
3
3
4
- import { composeContext , elizaLogger , ServiceType } from "@ai16z/eliza " ;
5
- import { getEmbeddingZeroVector } from "@ai16z/eliza " ;
4
+ import { composeContext , elizaLogger , ServiceType } from "@elizaos/core " ;
5
+ import { getEmbeddingZeroVector } from "@elizaos/core " ;
6
6
import {
7
7
Content ,
8
8
HandlerCallback ,
@@ -13,11 +13,11 @@ import {
13
13
State ,
14
14
UUID ,
15
15
Media ,
16
- } from "@ai16z/eliza " ;
17
- import { stringToUuid } from "@ai16z/eliza " ;
16
+ } from "@elizaos/core " ;
17
+ import { stringToUuid } from "@elizaos/core " ;
18
18
19
- import { generateMessageResponse , generateShouldRespond } from "@ai16z/eliza " ;
20
- import { messageCompletionFooter , shouldRespondFooter } from "@ai16z/eliza " ;
19
+ import { generateMessageResponse , generateShouldRespond } from "@elizaos/core " ;
20
+ import { messageCompletionFooter , shouldRespondFooter } from "@elizaos/core " ;
21
21
22
22
import { cosineSimilarity } from "./utils" ;
23
23
import {
@@ -702,7 +702,7 @@ export class MessageManager {
702
702
i === 0 && replyToMessageId
703
703
? { message_id : replyToMessageId }
704
704
: undefined ,
705
- parse_mode :' Markdown'
705
+ parse_mode : " Markdown" ,
706
706
}
707
707
) ) as Message . TextMessage ;
708
708
@@ -721,21 +721,17 @@ export class MessageManager {
721
721
try {
722
722
if ( / ^ ( h t t p | h t t p s ) : \/ \/ / . test ( imagePath ) ) {
723
723
// Handle HTTP URLs
724
- await ctx . telegram . sendPhoto (
725
- ctx . chat . id ,
726
- imagePath ,
727
- {
728
- caption,
729
- }
730
- ) ;
724
+ await ctx . telegram . sendPhoto ( ctx . chat . id , imagePath , {
725
+ caption,
726
+ } ) ;
731
727
} else {
732
- // Handle local file paths
728
+ // Handle local file paths
733
729
if ( ! fs . existsSync ( imagePath ) ) {
734
730
throw new Error ( `File not found: ${ imagePath } ` ) ;
735
731
}
736
-
732
+
737
733
const fileStream = fs . createReadStream ( imagePath ) ;
738
-
734
+
739
735
await ctx . telegram . sendPhoto (
740
736
ctx . chat . id ,
741
737
{
@@ -746,7 +742,7 @@ export class MessageManager {
746
742
}
747
743
) ;
748
744
}
749
-
745
+
750
746
elizaLogger . info ( `Image sent successfully: ${ imagePath } ` ) ;
751
747
} catch ( error ) {
752
748
elizaLogger . error ( "Error sending image:" , error ) ;
@@ -1085,7 +1081,7 @@ export class MessageManager {
1085
1081
for ( let i = 0 ; i < sentMessages . length ; i ++ ) {
1086
1082
const sentMessage = sentMessages [ i ] ;
1087
1083
const isLastMessage = i === sentMessages . length - 1 ;
1088
-
1084
+
1089
1085
const memory : Memory = {
1090
1086
id : stringToUuid (
1091
1087
sentMessage . message_id . toString ( ) +
@@ -1103,17 +1099,19 @@ export class MessageManager {
1103
1099
createdAt : sentMessage . date * 1000 ,
1104
1100
embedding : getEmbeddingZeroVector ( ) ,
1105
1101
} ;
1106
-
1102
+
1107
1103
// Set action to CONTINUE for all messages except the last one
1108
1104
// For the last message, use the original action from the response content
1109
1105
memory . content . action = ! isLastMessage
1110
1106
? "CONTINUE"
1111
1107
: content . action ;
1112
-
1113
- await this . runtime . messageManager . createMemory ( memory ) ;
1108
+
1109
+ await this . runtime . messageManager . createMemory (
1110
+ memory
1111
+ ) ;
1114
1112
memories . push ( memory ) ;
1115
1113
}
1116
-
1114
+
1117
1115
return memories ;
1118
1116
}
1119
1117
} ;
@@ -1125,14 +1123,12 @@ export class MessageManager {
1125
1123
state = await this . runtime . updateRecentMessageState ( state ) ;
1126
1124
1127
1125
// Handle any resulting actions
1128
-
1129
- const actionResult : any = await this . runtime . processActions (
1126
+ await this . runtime . processActions (
1130
1127
memory ,
1131
1128
responseMessages ,
1132
1129
state ,
1133
1130
callback
1134
1131
) ;
1135
- console . log ( "actionResult" , actionResult ) ;
1136
1132
}
1137
1133
1138
1134
await this . runtime . evaluate ( memory , state , shouldRespond ) ;
0 commit comments