Add Memory Gateway agent plugin
This commit is contained in:
42
plugins/memory-gateway-agent/tools.py
Normal file
42
plugins/memory-gateway-agent/tools.py
Normal file
@ -0,0 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
from .memory_gateway_plugin import tools as impl
|
||||
except ImportError:
|
||||
from memory_gateway_plugin import tools as impl
|
||||
|
||||
|
||||
def _json_result(payload: dict[str, Any]) -> str:
|
||||
return json.dumps(payload, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
def memory_search(args: dict[str, Any], **_: Any) -> str:
|
||||
return _json_result(impl.memory_search(**args))
|
||||
|
||||
|
||||
def memory_append_episode(args: dict[str, Any], **_: Any) -> str:
|
||||
return _json_result(impl.memory_append_episode(**args))
|
||||
|
||||
|
||||
def memory_commit_session(args: dict[str, Any], **_: Any) -> str:
|
||||
return _json_result(impl.memory_commit_session(**args))
|
||||
|
||||
|
||||
def memory_upsert(args: dict[str, Any], **_: Any) -> str:
|
||||
return _json_result(impl.memory_upsert(**args))
|
||||
|
||||
|
||||
def memory_feedback(args: dict[str, Any], **_: Any) -> str:
|
||||
return _json_result(impl.memory_feedback(**args))
|
||||
|
||||
|
||||
HANDLERS = {
|
||||
"memory_search": memory_search,
|
||||
"memory_append_episode": memory_append_episode,
|
||||
"memory_commit_session": memory_commit_session,
|
||||
"memory_upsert": memory_upsert,
|
||||
"memory_feedback": memory_feedback,
|
||||
}
|
||||
Reference in New Issue
Block a user