fix(client): new_memories_with_actions maybe a list or a dict
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
new_memories_with_actions variable in Memory._add_to_vector_store returns a list or a dict, when it returns a list, for resp in new_memories_with_actions["memory"]: block will report an error: ERROR:root:Error in new_memories_with_actions: list indices must be integers or slices, not str
some contexts:
I use qwen-turbo as LLM, and a custom openai_base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Please delete options that are not relevant.
- [ ] Test Script (please provide)
message = "I want to eat an apple"
client.add(
messages=message,
user_id="user1",
agent_id="agent1",
)
# until now is correct
message = "I want to eat an apple"
client.add(
messages=message,
user_id="user1",
agent_id="agent1",
)
# expect to add a memory or update the above memory
# but it reports the error, and no memory changes
# debug in `_add_to_vector_store`, the variable `new_memories_with_actions` is a list, so the error occurs
BTW: There has another way to fix is to change the prompt, maybe that will be a better patch
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
- [x] I have checked my code and corrected any misspellings
Maintainer Checklist
- [ ] Made sure Checks passed
Closing this PR, as the fix is already implemented. We really appreciate your efforts. Thanks a lot