mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-19 00:01:33 +00:00
- Replace ReMeClient with modular client implementations - Add component registry with type-based registration system - Introduce BaseClient extending BaseComponent with lifecycle management - Create HttpClient with environment-based service discovery - Add constants for default host/port configurations - Update service info propagation through environment variables - Restructure imports and exports across component modules - Add run_coro_safely utility for safe coroutine execution - Implement component type enumeration for better organization - Register components with R decorator for automatic discovery - Add placeholder methods for ReMe core functionalities - Update command-line entry point to use dynamic client selection
73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
import asyncio
|
|
import sys
|
|
|
|
from agentscope.formatter import FormatterBase
|
|
from agentscope.message import Msg
|
|
from agentscope.model import ChatModelBase
|
|
from agentscope.token import TokenCounterBase
|
|
from agentscope.tool import Toolkit, ToolResponse
|
|
|
|
from .application import Application
|
|
from .component import R
|
|
from .config import parse_args
|
|
from .enumeration import ComponentEnum
|
|
|
|
|
|
class ReMe(Application):
|
|
|
|
async def summary_memory(
|
|
self,
|
|
messages: list[Msg],
|
|
as_llm: str | ChatModelBase = "default",
|
|
as_llm_formatter: str | FormatterBase = "default",
|
|
as_token_counter: str | TokenCounterBase = "default",
|
|
toolkit: Toolkit | None = None,
|
|
language: str = "zh",
|
|
max_input_length: float = 128 * 1024,
|
|
compact_ratio: float = 0.7,
|
|
timezone: str | None = None,
|
|
add_thinking_block: bool = True,
|
|
) -> str:
|
|
...
|
|
|
|
async def memory_search(self, query: str, max_results: int = 5, min_score: float = 0.1) -> ToolResponse:
|
|
...
|
|
|
|
async def dream(
|
|
self,
|
|
as_llm: str | ChatModelBase = "default",
|
|
as_llm_formatter: str | FormatterBase = "default",
|
|
as_token_counter: str | TokenCounterBase = "default",
|
|
toolkit: Toolkit | None = None,
|
|
language: str = "zh",
|
|
timezone: str | None = None,
|
|
) -> str:
|
|
...
|
|
|
|
async def proactive(
|
|
self,
|
|
as_llm: str | ChatModelBase = "default",
|
|
as_llm_formatter: str | FormatterBase = "default",
|
|
as_token_counter: str | TokenCounterBase = "default",
|
|
toolkit: Toolkit | None = None,
|
|
language: str = "zh",
|
|
timezone: str | None = None,
|
|
) -> str:
|
|
...
|
|
|
|
|
|
def main():
|
|
action, config = parse_args(sys.argv[1:])
|
|
if action == "app":
|
|
reme = ReMe(**config)
|
|
reme.run_app()
|
|
|
|
else:
|
|
backend: str = config.pop("backend", "http")
|
|
client_cls = R.get(ComponentEnum.CLIENT, backend)
|
|
client = client_cls(action=action, **config)
|
|
asyncio.run(client())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|