-
Notifications
You must be signed in to change notification settings - Fork 83
[doc] Add documents for memory of flink-agents. #466
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?
Conversation
api/src/main/java/org/apache/flink/agents/api/memory/compaction/CompactionSetup.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Shekharrajak <shekharrajak@live.com>
address comments
address comments.
address comments.
| # store collection | ||
| memory.set("collection", [1, 2, 3]) | ||
| # store general class types | ||
| memory.set("object", LocalPrompt("the test {content}")) |
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.
| memory.set("object", LocalPrompt("the test {content}")) | |
| memory.set("object", Prompt.from_text("the test {content}")) |
| # store general class types | ||
| memory.set("object", LocalPrompt("the test {content}")) | ||
| # store memory object | ||
| memory.new_object("memory_object") |
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.
| memory.new_object("memory_object") | |
| obj1: MemoryObject = memory.new_object("obj1") | |
| obj1.set("foo", "bar") |
| value1: int = memory.get("primitive") | ||
| value2: List[int] = memory.get("collection") | ||
| value3: Prompt = memory.get("object") | ||
| value4: MemoryObject = memory.get("memory_object") |
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.
| value4: MemoryObject = memory.get("memory_object") | |
| value4: MemoryObject = memory.get("obj1") | |
| value5: str = value4.get("foo") |
| // store general class types | ||
| memory.set("object", new LocalPrompt("the test {content}")); | ||
| // store memory object | ||
| memory.newObject("memory_object", true); // The second argument means whether to overwrite existing field if it's not a nested object |
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.
I think we should add an overload method that does not require the second argument and use false for default (aligned with python), and use that for the example.
| // store general class types | ||
| memory.set("object", new LocalPrompt("the test {content}")); | ||
| // store memory object | ||
| memory.newObject("memory_object", true); // The second argument means whether to overwrite existing field if it's not a nested object |
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.
| memory.newObject("memory_object", true); // The second argument means whether to overwrite existing field if it's not a nested object | |
| MemoryObject obj1 = memory.newObject("obj1", true); // The second argument means whether to overwrite existing field if it's not a nested object | |
| obj1.set("foo", "bar"); |
| * Use `new_object` to manually create nested field. | ||
| * Use dot-separated path as key to created nested field. |
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.
This doesn't seem right. "Always using new_object for creating memory objects" is something we need to emphasis, but it's not a way of accessing the fields.
| * Use `new_object` to manually create nested field. | ||
| * Use dot-separated path as key to created nested field. |
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.
| * Use `new_object` to manually create nested field. | |
| * Use dot-separated path as key to created nested field. | |
| * Use `new_object` to manually create nested field. | |
| * Use dot-separated path as key to access nested field. |
|
|
||
| {{< tab "Python" >}} | ||
| ```python | ||
| # Use new_object |
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.
| # Use new_object | |
| # access fields from the innermost memory object with field names |
| name: str = user.get("name") | ||
| age: int = user.get("age") | ||
|
|
||
| # Use dot-separated path |
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.
| # Use dot-separated path | |
| # access fields from an outer memory object with paths to the fields |
|
|
||
| ### Memory Reference | ||
|
|
||
| `MemoryRef` is a reference of the objects stored in memory. The `set` method memory object will return a `MemoryRef`. |
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.
| `MemoryRef` is a reference of the objects stored in memory. The `set` method memory object will return a `MemoryRef`. | |
| `MemoryRef` is a reference of the objects stored in memory. The `set` method of memory object will return a `MemoryRef`. |
Linked issue: #350 and #351
Purpose of change
Refactor the doc organization for flink-agents memory, and add docs for sensory and long-term memory.
This pr is based on #401 and #402.
Tests
No
API
No
Documentation
doc-neededdoc-not-neededdoc-included