Open HFR1994 opened 1 month ago
Hello. I am facing the same problem.
I think the format of json_body is different between command-r and command, so I have to rewrite the following.
# Command-R
if messages:
input_body["chat_history"] = messages['chat_history']
input_body["message"] = messages['message']
# Command
else:
input_body["prompt"] = prompt
I assume that Command R will be currently unsupported, just as Claude3 does not support BedrockBase. https://github.com/langchain-ai/langchain-aws/blob/main/libs/aws/langchain_aws/llms/bedrock.py#L744
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
model_id = values["model_id"]
if model_id.startswith("anthropic.claude-3"):
raise ValueError(
"Claude v3 models are not supported by this LLM."
"Please use `from langchain_community.chat_models import BedrockChat` "
"instead."
)
return super().validate_environment(values)
It would be better to use ChatBedrock for this purpose.
I am now implementing my own Rv request with the following PR. https://github.com/langchain-ai/langchain-aws/pull/42
I was trying to do my own commit; however, I'm not really sure how to locally test it. Any pointers @ksaegusa?
@HFR1994 I followed the steps below to install my repository locally:
git clone https://github.com/ksaegusa/langchain-aws.git
cd langchain-aws
git switch add_cohere_model
pip install -e libs/aws/
After that, I wrote a simple script to verify the functionality.
I hope this answers your question
Thanks for this update!
Any news on when https://github.com/langchain-ai/langchain-aws/issues/43 will be merged?
I'm using the
cohere.command-r-v1:0
model to test some prompts. After noticing that Cohere doesn't support Chat #33, I changed to BedrockLLM. However I keep getting the following message:ValueError: Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #: required key [message] not found#: extraneous key [prompt] is not permitted, please reformat your input and try again.
I have tried several methods including:
After validating the error message and line 134 in libs/aws/langchain_aws/llm/bedrock I think it should be rewritten as:
Here are my dependencies:
langchain==0.1.19 langchain-aws==0.1.3
I'm using Python 3.11