I have this code that just creates tags for each document. I have done it with ChatOpenAI(), and it works perfectly, but when I change to BedrockChat(), I get the error. This is the code.
from langchain_community.chat_models import BedrockChat,
from langchain.chains import create_tagging_chain_pydantic
class Tags(BaseModel):
sql: str = Field(
description="Whether the text fragment includes sql code.",
default="False",
)
python: str = Field(
description="Whether the text fragment includes python code.",
default="False",
)
tagging_chain = create_tagging_chain_pydantic(pydantic_schema=Tags,
llm = BedrockChat(model_id="anthropic.claude-v2") ,
prompt=self.tagging_prompt)
tagging_results = tagging_chain.batch(
inputs=[{"input": doc.page_content} for doc in docs],
return_exceptions=True,
config={
"max_concurrency": 5,
},
)
I got this error:
Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #: extraneous key [functions] is not permitted#: extraneous key [function_call] is not permitted, please reformat your input and try again.
When I print this:
print(tagging_chain.llm_kwargs)
{'functions': [{...}], 'function_call': {'name': 'information_extraction'}}
print(tagging_chain.llm_kwargs.get("functions"))
[{'name': 'information_extraction', 'description': 'Extracts the relevan...e passage.', 'parameters': {...}}]
How can fix this error?