-
Notifications
You must be signed in to change notification settings - Fork 276
Feat/memory impl #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/memory impl #157
Conversation
|
||
async def chat( | ||
self, | ||
messages: list[ArkMessage], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得ArkMessage
其实叫Message
就挺好的,加个Ark有点怪。
对等的,比如OpenaiMessage
or VetexAIMessage
听起来是不是都有点怪..
不过这个还好改吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哎这个结构由来已久了 感觉不太好改了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样呢?只留一个 def ArkMessage(Message) 的定义,其他用户代码如果引用了 ArkMessage 可以继续用,但我们自己的代码里,就全都改成直接用 Message
] | ||
|
||
|
||
class ResponsesClientWithLongTermMemory: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉 ResponsesClientWithLongTermMemory 可以作为一个基础组件,可以从 examples 里摘出来
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 先做为了一个参考实现,consolidate下放进去
memories = self.memory[user_id] | ||
results = "用户过去的交互记录\n\n" | ||
for memory in memories: | ||
content = format_ark_message_as_string(memory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同理,这里没有必要把 ark 也带上;
另外,用户的原始 query 是不是最好也能带上呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯在update memory的时候 这个list里面默认是带用户原始query的
new_messages: list[ArkMessage | dict | Response | ChatCompletionMessage], | ||
**kwargs: Any, | ||
) -> None: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_or_update有点冗长,叫upsert_memory
呢?
然后接口感觉可以扩展成
@abstractmethod async def upsert_memory( self, user_id: str, data: list[Any], source: DataSource = DataSource.CHAT_MESSAGE, # 将来可以扩展更多的入库的数据,不单单局限在对话的message **kwargs: Any, ) -> None: ...
从而将来可以接入更多数据源,而不单单是对话消息
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯 我觉得要不先把new_messages 改为data: list[Any] 吧,其他source 之后需要加了再加上?暂时不放在base 的interface里
不一定强求所有实现都可以支持各种datasource,但来自message的应该是都会支持的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好,我其实想留一个 datasource 是想让接口看起来不是专门针对对话消息的,将来可能可以继续扩展出来各种生产资料,比如doc啥的
5b04309
to
ab6e8f2
Compare
No description provided.