aws-samples / generative-ai-amazon-bedrock-langchain-agent-example

MIT No Attribution
221 stars 393 forks source link

ValueError: Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: The requested operation is not recognized by the service. #4

Closed NingLu closed 12 months ago

NingLu commented 1 year ago

After deployment, i type in Demo User and 1234, and can see 3 buttons in the Lex bot. Then typing "Good morning", and see this error

It is raised in this code snippet

    llm = Bedrock(
        model_id="anthropic.claude-instant-v1"
    )  
    llm.model_kwargs = {'max_tokens_to_sample': 200}
    lex_agent = FSIAgent(llm, chat.memory)

    try:
        message = lex_agent.run(input=prompt)
Screenshot 2023-10-18 at 21 46 58
awsartisan commented 1 year ago

I'm getting the same error. I had hoped that pip install -U langchain might fix this, but it didn't.

kyleblocksom commented 1 year ago

I was not able to replicate the error in my environment, however, I reintroduced _FORMATINSTRUCTIONS into the fsi_agent.py class. Please re-test and let me know your findings.

dgghosalaws commented 1 year ago

The issue is still observed. There are not enough details except

Setting Chat History
--
Initializing FSI Agent
Creating FSI Agent - Start
Creating FSI Agent - Middle
Creating FSI Agent - End
Running FSI Agent with input = What kind of questions can FSI Agent answer?
> Entering new AgentExecutor chain...
Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: The requested operation is not recognized by the service.
[ERROR] ValueError: Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: The requested operation is not recognized by the service.Traceback (most recent call last):  File "/var/task/lambda_function.py", line 851, in handler    return dispatch(event)  File "/var/task/lambda_function.py", line 835, in dispatch    return genai_intent(intent_request)  File "/var/task/lambda_function.py", line 813, in genai_intent    output = invoke_fm(intent_request)  File "/var/task/lambda_function.py", line 796, in invoke_fm    raise e
kyleblocksom commented 12 months ago

Resolved with Python 3.11, LangChain 1.28.64 patch.