mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-10-07 03:00:27 +00:00
style(formatting): standardize code formatting and logging statements
This commit is contained in:
parent
0b7843f557
commit
2d98169d80
5 changed files with 31 additions and 19 deletions
|
|
@ -42,7 +42,7 @@ class BaseEmbeddingModel(ABC):
|
|||
"""Truncate text to max_input_length if it exceeds the limit."""
|
||||
if len(text) > self.max_input_length:
|
||||
logger.warning(
|
||||
f"Text length {len(text)} exceeds max_input_length {self.max_input_length}, truncating"
|
||||
f"Text length {len(text)} exceeds max_input_length {self.max_input_length}, truncating",
|
||||
)
|
||||
return text[: self.max_input_length]
|
||||
return text
|
||||
|
|
@ -77,7 +77,7 @@ class BaseEmbeddingModel(ABC):
|
|||
"""Async get embeddings with automatic batching and exponential backoff retries."""
|
||||
# Truncate all input texts first
|
||||
truncated_texts = self._truncate_texts(input_text)
|
||||
|
||||
|
||||
# Split into batches and process sequentially to respect rate limits
|
||||
results = []
|
||||
for i in range(0, len(truncated_texts), self.max_batch_size):
|
||||
|
|
@ -118,7 +118,7 @@ class BaseEmbeddingModel(ABC):
|
|||
"""Synchronous get embeddings with automatic batching and retry logic."""
|
||||
# Truncate all input texts first
|
||||
truncated_texts = self._truncate_texts(input_text)
|
||||
|
||||
|
||||
results = []
|
||||
for i in range(0, len(truncated_texts), self.max_batch_size):
|
||||
batch = truncated_texts[i : i + self.max_batch_size]
|
||||
|
|
|
|||
|
|
@ -102,7 +102,10 @@ class BaseMemoryAgent(BaseOp, metaclass=ABCMeta):
|
|||
**kwargs,
|
||||
)
|
||||
messages.append(assistant_message)
|
||||
logger.info(f"[{self.__class__.__name__}] step{step + 1}.assistant={assistant_message.simple_dump(enable_json_dump=True)}")
|
||||
logger.info(
|
||||
f"[{self.__class__.__name__}] "
|
||||
f"step{step + 1}.assistant={assistant_message.simple_dump(enable_json_dump=True)}",
|
||||
)
|
||||
should_act = bool(assistant_message.tool_calls)
|
||||
return assistant_message, should_act
|
||||
|
||||
|
|
@ -119,7 +122,10 @@ class BaseMemoryAgent(BaseOp, metaclass=ABCMeta):
|
|||
logger.warning(f"[{self.__class__.__name__}] unknown tool_call.name={tool_call.name}")
|
||||
continue
|
||||
|
||||
logger.info(f"[{self.__class__.__name__}] step{step + 1}.{j} submit tool_calls={tool_call.name} argument={tool_call.arguments}")
|
||||
logger.info(
|
||||
f"[{self.__class__.__name__}] step{step + 1}.{j} "
|
||||
f"submit tool_calls={tool_call.name} argument={tool_call.arguments}",
|
||||
)
|
||||
tool_copy: BaseMemoryTool = tool_dict[tool_call.name].copy()
|
||||
tool_copy.tool_call.id = tool_call.id
|
||||
tool_list.append(tool_copy)
|
||||
|
|
@ -162,10 +168,15 @@ class BaseMemoryAgent(BaseOp, metaclass=ABCMeta):
|
|||
async def execute(self):
|
||||
messages = await self.build_messages()
|
||||
for i, message in enumerate(messages):
|
||||
logger.info(f"[{self.__class__.__name__}] step0.{i} {message.role} {message.name or ''} "
|
||||
f"{message.simple_dump(enable_json_dump=True)}")
|
||||
logger.info(
|
||||
f"[{self.__class__.__name__}] step0.{i} {message.role} {message.name or ''} "
|
||||
f"{message.simple_dump(enable_json_dump=True)}",
|
||||
)
|
||||
for i, tool in enumerate(self.tools):
|
||||
logger.info(f"[{self.__class__.__name__}] step0.{i} tool_call={json.dumps(tool.tool_call.simple_input_dump(), ensure_ascii=False)}")
|
||||
logger.info(
|
||||
f"[{self.__class__.__name__}] step0.{i} "
|
||||
f"tool_call={json.dumps(tool.tool_call.simple_input_dump(), ensure_ascii=False)}",
|
||||
)
|
||||
|
||||
self.messages, self.success = await self.react(messages)
|
||||
if self.success and self.messages:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
"""Orchestrator for complete memory summarization workflow across all memory types."""
|
||||
|
||||
import re
|
||||
from typing import List
|
||||
|
||||
from loguru import logger
|
||||
|
|
|
|||
|
|
@ -104,5 +104,7 @@ class BaseMemoryTool(BaseOp, metaclass=ABCMeta):
|
|||
metadata=metadata or {},
|
||||
)
|
||||
|
||||
logger.opt(depth=1).info(f"[{self.__class__.__name__}] build node={node.model_dump_json(indent=2, exclude_none=True)}")
|
||||
return node
|
||||
logger.opt(depth=1).info(
|
||||
f"[{self.__class__.__name__}] build node={node.model_dump_json(indent=2, exclude_none=True)}",
|
||||
)
|
||||
return node
|
||||
|
|
|
|||
|
|
@ -64,14 +64,14 @@ class AddSummaryMemory(AddMemory):
|
|||
}
|
||||
|
||||
def _build_memory_node(
|
||||
self,
|
||||
memory_content: str,
|
||||
memory_type: MemoryType | None = None,
|
||||
memory_target: str = "",
|
||||
ref_memory_id: str = "",
|
||||
when_to_use: str = "",
|
||||
author: str = "",
|
||||
metadata: dict | None = None,
|
||||
self,
|
||||
memory_content: str,
|
||||
memory_type: MemoryType | None = None,
|
||||
memory_target: str = "",
|
||||
ref_memory_id: str = "",
|
||||
when_to_use: str = "",
|
||||
author: str = "",
|
||||
metadata: dict | None = None,
|
||||
) -> MemoryNode:
|
||||
"""Build MemoryNode from content, when_to_use, and metadata."""
|
||||
node = MemoryNode(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue