Skip to content

Commit

Permalink
Merge branch 'develop' into tcm-imageVisionModelProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 authored Jan 30, 2025
2 parents 264ce5e + 7d6951a commit dd44598
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
20 changes: 7 additions & 13 deletions packages/client-telegram/src/messageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,9 @@ export class MessageManager {

// Check if we should post
if (
timeSinceLastMessage >
this.autoPostConfig.inactivityThreshold ||
(randomThreshold &&
timeSinceLastAutoPost >
(this.autoPostConfig.minTimeBetweenPosts || 0))
timeSinceLastMessage > randomThreshold &&
timeSinceLastAutoPost >
(this.autoPostConfig.minTimeBetweenPosts || 0)
) {
try {
const roomId = stringToUuid(
Expand Down Expand Up @@ -258,7 +256,7 @@ export class MessageManager {
// Create and store memories
const memories = messages.map((m) => ({
id: stringToUuid(
m.message_id.toString() + "-" + this.runtime.agentId
roomId + "-" + m.message_id.toString()
),
userId: this.runtime.agentId,
agentId: this.runtime.agentId,
Expand Down Expand Up @@ -384,9 +382,7 @@ export class MessageManager {
);

const memories = messages.map((m) => ({
id: stringToUuid(
m.message_id.toString() + "-" + this.runtime.agentId
),
id: stringToUuid(roomId + "-" + m.message_id.toString()),
userId: this.runtime.agentId,
agentId: this.runtime.agentId,
content: {
Expand Down Expand Up @@ -1264,7 +1260,7 @@ export class MessageManager {

// Get message ID
const messageId = stringToUuid(
message.message_id.toString() + "-" + this.runtime.agentId
roomId + "-" + message.message_id.toString()
) as UUID;

// Handle images
Expand Down Expand Up @@ -1339,9 +1335,7 @@ export class MessageManager {

const memory: Memory = {
id: stringToUuid(
sentMessage.message_id.toString() +
"-" +
this.runtime.agentId
roomId + "-" + sentMessage.message_id.toString()
),
agentId,
userId: agentId,
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ export function extractAttributes(
* - Wraps unquoted values in double quotes.
* - Converts single-quoted values to double-quoted.
* - Ensures consistency in key-value formatting.
* - Collapses multiple double quotes into a single one.
* - Normalizes mixed adjacent quote pairs.
*
* This is useful for cleaning up improperly formatted JSON strings
Expand Down Expand Up @@ -251,11 +250,8 @@ export const normalizeJsonString = (str: string) => {
// "key": someWord → "key": "someWord"
str = str.replace(/("[\w\d_-]+")\s*:\s*([A-Za-z_]+)(?!["\w])/g, '$1: "$2"');

// Collapse multiple double quotes ("") into one
str = str.replace(/"+/g, '"');

// Replace adjacent quote pairs with a single double quote
str = str.replace(/(["'])(['"])/g, '"');
str = str.replace(/(?:"')|(?:'")/g, '"');
return str;
};

Expand Down

0 comments on commit dd44598

Please sign in to comment.