Skip to content
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

AWSBedrockLLM.generate_response() got an unexpected keyword argument 'response_format' #1910

Closed
ketvector opened this issue Sep 26, 2024 · 2 comments · Fixed by #1927
Closed
Assignees
Labels
bug Something isn't working

Comments

@ketvector
Copy link

🐛 Describe the bug

Using locally, version 0.1.16 with the config in the code.

>>> import mem0
>>> mem0.__version__
'0.1.16'
import os

os.environ['AWS_REGION'] = "my-region"
os.environ['AWS_ACCESS_KEY']="my-key"
os.environ['AWS_SECRET_ACCESS_KEY']="my-secret"

config = {
    "llm": {
        "provider": "aws_bedrock",
        "config": {
            "model": "arn:aws:bedrock:ap-south-1::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0",
            "temperature": 0.2,
            "max_tokens": 1500,
        }
    },
    "vector_store": {
        "provider": "qdrant",
        "config": {
            "url": "my-url",
            "api_key": "my-key"
        }
    },
    "embedder": {
        "provider": "huggingface"
    }
}

m = Memory.from_config(config)

# 1. Add: Store a memory from any unstructured text
result = m.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="me", metadata={"category": "hobbies"})

Running it locally, when using AWS bedrock anthropic, I am getting the following error.

  File "/Users/neeraj/Code/t-mem0/main.py", line 33, in <module>
    result = m.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="neeraj", metadata={"category": "hobbies"})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/neeraj/Code/t-mem0/lib/python3.12/site-packages/mem0/memory/main.py", line 109, in add
    vector_store_result = future1.result()
                          ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/neeraj/Code/t-mem0/lib/python3.12/site-packages/mem0/memory/main.py", line 136, in _add_to_vector_store
    response = self.llm.generate_response(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AWSBedrockLLM.generate_response() got an unexpected keyword argument 'response_format'

The error looks to be because AWSBedrockLLM has the following signature

def generate_response(
        self,
        messages: List[Dict[str, str]],
        tools: Optional[List[Dict]] = None,
        tool_choice: str = "auto",
    ):

This looks to be a very basic miss. Am I doing something wrong, or is AWSBedrockLLM not widely used ?

@rafael-bianchi
Copy link

Same problem here. Also, it would be nice to use models in bedrock for the embedder config.

@NavyaAlapati13
Copy link
Contributor

Please assign this issue to me @Dev-Khant, will raise a PR for this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants