xintongsong commented on code in PR #629:
URL: https://github.com/apache/flink-agents/pull/629#discussion_r3098285160
##########
python/flink_agents/api/memory/long_term_memory.py:
##########
@@ -15,95 +15,54 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#################################################################################
-import importlib
from abc import ABC, abstractmethod
from datetime import datetime
-from enum import Enum
-from typing import Any, Dict, List, Type
+from typing import Any, Dict, List
-from pydantic import (
- BaseModel,
- Field,
- field_serializer,
- model_validator,
-)
+from pydantic import BaseModel, Field
-from flink_agents.api.chat_message import ChatMessage
from flink_agents.api.configuration import ConfigOption
-from flink_agents.api.prompts.prompt import Prompt
-
-ItemType = str | ChatMessage
-
-
-class CompactionConfig(BaseModel):
- """Compaction configuration.
-
- Attributes:
- model: The name of the llm used for generating the summarization.
- prompt: The prompt instance or name of the prompt used for generating
- the summarization. Optional.
- limit: How many summarization should generate for the context.
Defaults to 1.
- """
-
- model: str
- prompt: str | Prompt | None = None
- limit: int = 1
-
-
-class LongTermMemoryBackend(Enum):
- """Backend for Long-Term Memory."""
-
- EXTERNAL_VECTOR_STORE = "external_vector_store"
class LongTermMemoryOptions:
- """Config options for ReActAgent."""
+ """Config options for Long-Term Memory."""
- BACKEND = ConfigOption(
- key="long-term-memory.backend",
- config_type=LongTermMemoryBackend,
+ CHAT_MODEL_SETUP = ConfigOption(
+ key="long-term-memory.chat-model-setup",
+ config_type=str,
default=None,
)
- EXTERNAL_VECTOR_STORE_NAME = ConfigOption(
- key="long-term-memory.external-vector-store-name",
+ EMBEDDING_MODEL_SETUP = ConfigOption(
+ key="long-term-memory.embedding-model-setup",
config_type=str,
default=None,
)
- ASYNC_COMPACTION = ConfigOption(
- key="long-term-memory.async-compaction",
- config_type=bool,
- default=True,
+ VECTOR_STORE = ConfigOption(
+ key="long-term-memory.vector-store",
+ config_type=dict,
+ default=None,
Review Comment:
1. I'd suggest the names `long-term-memory.mem0.xxx`, in case we introduce
more backends in future.
2. Having a `dict` type config option can be troublesome. Why is the vector
store configured differently compared to chat and embedding model?
##########
python/flink_agents/runtime/flink_runner_context.py:
##########
@@ -770,17 +769,17 @@ def create_flink_runner_context(
j_runner_context, agent_plan_json, executor, j_resource_adapter
)
- backend = ctx.config.get(LongTermMemoryOptions.BACKEND)
- # use external vector store based long term memory
- if backend == LongTermMemoryBackend.EXTERNAL_VECTOR_STORE:
- vector_store_name = ctx.config.get(
- LongTermMemoryOptions.EXTERNAL_VECTOR_STORE_NAME
- )
+ chat_model_name = ctx.config.get(LongTermMemoryOptions.CHAT_MODEL_SETUP)
+ embedding_model_name =
ctx.config.get(LongTermMemoryOptions.EMBEDDING_MODEL_SETUP)
+ if chat_model_name is not None and embedding_model_name is not None:
+ vector_store_config =
ctx.config.get(LongTermMemoryOptions.VECTOR_STORE)
ctx.set_long_term_memory(
- VectorStoreLongTermMemory(
+ Mem0LongTermMemory(
ctx=ctx,
- vector_store=vector_store_name,
job_id=job_identifier,
+ chat_model_name=chat_model_name,
+ embedding_model_name=embedding_model_name,
+ vector_store_config=vector_store_config,
Review Comment:
The initialization of ltm-beckend might worth a separate function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]