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

Prompt caching does not work, cachePoint object not supported #326

Open
ShaharZivanOnvego opened this issue Jan 14, 2025 · 2 comments
Open
Labels
bedrock enhancement New feature or request

Comments

@ShaharZivanOnvego
Copy link

ShaharZivanOnvego commented Jan 14, 2025

To use prompt caching, according to the AWS Bedrock documentation, the system message needs to look like this:

...
  "system": [ 
    {
        "text": "You are an app that creates play lists for a radio station that plays rock and pop music. Only return song names and the artist. "
    },
    {
        "cachePoint": {
            "type": "default"
        }
    }
  ],
...

However, when trying to do this as a SystemMessage through Langchain, I get the following error:

System message must be a string, instead was: <class 'list'> Traceback (most recent call last):
  File "/home/shahar/ProjectData/AgentFramework/onvego/agent_framework/task_handler/internal.py", line 318, in __call__

If I initialize ChatBedrock with the flag beta_use_converse_api=True, then it does let me send a list - but when this list has the cachepoint object as specified:

{
    "cachePoint": {
        "type": "default",
    }
}

I get an error stating:

Parameter validation failed:
Unknown parameter in system[1]: "cachePoint", must be one of: text, guardContent

This seems to make cache prompting impossible, unless I am missing something.

@langcarl langcarl bot added the investigate label Jan 14, 2025
@ShaharZivanOnvego ShaharZivanOnvego changed the title Prompt caching does not work, as it requires SystemMessage to be a list Prompt caching does not work, cachePoint object not supported Jan 14, 2025
@stanyq4
Copy link

stanyq4 commented Jan 20, 2025

As the number of our tools is constantly growing, we are also looking to utilize cachePoint param.

Is there any update on when this might be available? Sound like it should be a minor fix.

Thank you

@masquare
Copy link

masquare commented Jan 21, 2025

Amazon Bedrock prompt caching is still in preview and as such, the new cachePoint parameter for system messages is not yet supported by botocore (see here).

We need botocore/boto3 to support the cachePoint parameter for system messages before langchain-aws can integrate it.

Tracking the boto3 release in boto/boto3#4376

@3coins 3coins added enhancement New feature or request bedrock and removed investigate labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bedrock enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants