Add generic MemoryTool and Anthropic-native MemoryTool#119
Add generic MemoryTool and Anthropic-native MemoryTool#119KavyaSree2610 wants to merge 10 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #119 +/- ##
==========================================
+ Coverage 95.88% 96.59% +0.70%
==========================================
Files 26 29 +3
Lines 1046 1379 +333
==========================================
+ Hits 1003 1332 +329
- Misses 43 47 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…sing exceptions and add tests
Co-authored-by: KavyaSree2610 <92566732+KavyaSree2610@users.noreply.github.com>
bad1c47 to
abba902
Compare
0xba1a
left a comment
There was a problem hiding this comment.
Can you please explain why this _dispatch_tool_use and native_tool concept is necessary?
I can understand the requirement for AnthropicMemoryTool wrapper over the generic MemoryTool. But can't that be simply used as an ExternalTool itself? IMO, the logic of _dispatch_tool_use can be handled in the ask itself, right? It acts as a tool_call wrapper every tool call (internal and external).
I think we can pass all the tools (not just the native-tools) in the tools argument of Anthropic API call. When every-tool can be passed via this, we may not even need a nativeTool abstraction.
You can silently upgrade generic MemoryTool into AnthropicMemoryTool inside the anthropic_api's __init__
| self._memory_dir = base | ||
| self._memory_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| def is_model_supported(self, model_name: str) -> bool: |
There was a problem hiding this comment.
This overriding is required here as it exhibits the default behavior of ToolAbstract
There was a problem hiding this comment.
I believe you mean it is not required
src/microbots/MicroBot.py
Outdated
| folder_to_mount=folder_to_mount, | ||
| ) | ||
|
|
||
| def _upgrade_tools_for_provider(self): |
There was a problem hiding this comment.
Let's move this function to the LLM class itself. Each LLM can have an independent logic to control this behavior.
src/microbots/MicroBot.py
Outdated
| self.additional_tools = upgraded | ||
|
|
||
| def _create_llm(self): | ||
| self._upgrade_tools_for_provider() |
There was a problem hiding this comment.
I think we may not even need this explicit call. We can allow the LLM to silently replace tools with optimised native-tool
src/microbots/llm/anthropic_api.py
Outdated
| # Dispatch any tool_use rounds before looking for a JSON response. | ||
| # The model may call the memory tool multiple times before producing | ||
| # its final JSON command. | ||
| while response.stop_reason == "tool_use": |
No description provided.