mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-10-07 03:00:27 +00:00
chore(version): bump version to 0.3.0.0a4 and add logging
This commit is contained in:
parent
e70d19a201
commit
679fafee1f
8 changed files with 29 additions and 23 deletions
|
|
@ -18,7 +18,7 @@ __all__ = [
|
|||
"ReMeFs",
|
||||
]
|
||||
|
||||
__version__ = "0.3.0.0a3"
|
||||
__version__ = "0.3.0.0a4"
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from ...core.enumeration import Role, ChunkEnum
|
||||
from ...core.op import BaseReactStream
|
||||
from ...core.schema import Message, StreamChunk
|
||||
|
|
@ -164,6 +166,9 @@ class FsCli(BaseReactStream):
|
|||
_ = await self.compact(force_compact=False)
|
||||
|
||||
messages = await self.build_messages()
|
||||
for i, message in enumerate(messages):
|
||||
role = message.name or message.role
|
||||
logger.info(f"[{self.__class__.__name__}] role={role} {message.simple_dump(as_dict=False)}")
|
||||
|
||||
t_tools, messages, success = await self.react(messages, self.tools)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ on any change, ensuring complete synchronization.
|
|||
|
||||
import asyncio
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from loguru import logger
|
||||
from watchfiles import Change
|
||||
|
|
@ -27,18 +28,17 @@ class FullFileWatcher(BaseFileWatcher):
|
|||
|
||||
@staticmethod
|
||||
async def _build_file_metadata(path: str) -> FileMetadata:
|
||||
file_path = Path(path)
|
||||
|
||||
def _read_file_sync():
|
||||
stat_t = os.stat(path)
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
content_t = f.read()
|
||||
return stat_t, content_t
|
||||
return file_path.stat(), file_path.read_text(encoding="utf-8")
|
||||
|
||||
stat, content = await asyncio.to_thread(_read_file_sync)
|
||||
return FileMetadata(
|
||||
hash=hash_text(content),
|
||||
mtime_ms=stat.st_mtime * 1000,
|
||||
size=stat.st_size,
|
||||
path=path,
|
||||
path=str(file_path.absolute()),
|
||||
content=content,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -101,10 +101,10 @@ class LiteLLM(BaseLLM):
|
|||
|
||||
delta = chunk.choices[0].delta
|
||||
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.THINK, chunk=delta.reasoning_content)
|
||||
|
||||
if delta.content is not None:
|
||||
if delta.content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.ANSWER, chunk=delta.content)
|
||||
|
||||
if hasattr(delta, "tool_calls") and delta.tool_calls is not None:
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ class LiteLLMSync(LiteLLM):
|
|||
|
||||
delta = chunk.choices[0].delta
|
||||
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.THINK, chunk=delta.reasoning_content)
|
||||
|
||||
if delta.content is not None:
|
||||
if delta.content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.ANSWER, chunk=delta.content)
|
||||
|
||||
if hasattr(delta, "tool_calls") and delta.tool_calls is not None:
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ class OpenAILLM(BaseLLM):
|
|||
|
||||
delta = chunk.choices[0].delta
|
||||
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.THINK, chunk=delta.reasoning_content)
|
||||
|
||||
if delta.content is not None:
|
||||
if delta.content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.ANSWER, chunk=delta.content)
|
||||
|
||||
if delta.tool_calls is not None:
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ class OpenAILLMSync(OpenAILLM):
|
|||
|
||||
delta = chunk.choices[0].delta
|
||||
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
|
||||
if hasattr(delta, "reasoning_content") and delta.reasoning_content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.THINK, chunk=delta.reasoning_content)
|
||||
|
||||
if delta.content is not None:
|
||||
if delta.content:
|
||||
yield StreamChunk(chunk_type=ChunkEnum.ANSWER, chunk=delta.content)
|
||||
|
||||
if delta.tool_calls is not None:
|
||||
|
|
|
|||
|
|
@ -293,33 +293,34 @@ class ReMeFs(Application):
|
|||
while True:
|
||||
try:
|
||||
# Get user input (async)
|
||||
user_input = await session.prompt_async("You: ", default="")
|
||||
if not user_input.strip():
|
||||
user_input = await session.prompt_async("You: ")
|
||||
user_input = user_input.strip()
|
||||
if not user_input:
|
||||
continue
|
||||
|
||||
# Handle commands
|
||||
if user_input.strip() == "/exit":
|
||||
if user_input == "/exit":
|
||||
break
|
||||
|
||||
if user_input.strip() == "/new":
|
||||
if user_input == "/new":
|
||||
result = await fs_cli.reset()
|
||||
print(f"{result}\nConversation reset\n")
|
||||
continue
|
||||
|
||||
if user_input.strip() == "/compact":
|
||||
if user_input == "/compact":
|
||||
result = await fs_cli.compact(force_compact=True)
|
||||
print(f"{result}\nHistory compacted.\n")
|
||||
continue
|
||||
|
||||
if user_input.strip() == "/clear":
|
||||
if user_input == "/clear":
|
||||
fs_cli.messages.clear()
|
||||
print("History cleared.\n")
|
||||
continue
|
||||
|
||||
if user_input.strip() == "/help":
|
||||
if user_input == "/help":
|
||||
print("\nCommands:")
|
||||
for command in self.commands:
|
||||
print(f" {command}")
|
||||
for command, description in self.commands.items():
|
||||
print(f" {command}: {description}")
|
||||
continue
|
||||
|
||||
# Stream processing state
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue