跳至內容

Bedrock invoke agent 'overrideSearchType' =HYBRID does not work

0

I'm using below knowledgeBaseConfigurations to invoke bedrock agent. it cannot find the query. but I test the same query in known based console with search type: HYBRID, I can get query result.

def _invoke_agent(username, sessionId, user_query):
    response = bedrock_agent.invoke_agent(
       agentAliasId=agent_alias_id,
       agentId=agent_id,
       sessionId=sessionId,
       enableTrace=True,
       inputText=user_query,
       sessionState={
           'knowledgeBaseConfigurations' : [
               {
                   'knowledgeBaseId': knowledge_base_id,
                   'retrievalConfiguration': {
                       'vectorSearchConfiguration': {
                            'numberOfResults': 10,
                    **        'overrideSearchType': 'HYBRID'**
                       }
                   }
               } 
           ],
            'promptSessionAttributes': {
                'username': username
            },
            
            'sessionAttributes': {
                'username': username
            }, 
       } 
    )

  • Hi, can you update your question with the error message that you get ?

已提問 2 年前檢視次數 492 次

2 個答案
1

Hi,

As per https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_KnowledgeBaseVectorSearchConfiguration.html#bedrock-Type-agent-runtime_KnowledgeBaseVectorSearchConfiguration-overrideSearchType using the value HYBRID is valid. And it works from console.

So, you should suspect something else: 1/ your code runs from somewhere where it can't access the Bedrock endpoint 2/ missing IAM policy to allow your code to access endpoint 3/ etc,

Can you provide more details on the error you get ?

Best,

Didier

專家

已回答 2 年前

專家

已審閱 2 年前

  • overrideSearchType By default, Amazon Bedrock decides a search strategy for you. If you're using an Amazon OpenSearch Serverless vector store that contains a filterable text field, you can specify whether to query the knowledge base with a HYBRID search using both vector embeddings and raw text, or SEMANTIC search using only vector embeddings. For other vector store configurations, only SEMANTIC search is available. For more information, see Test a knowledge base.

    Type: String

    Valid Values: HYBRID | SEMANTIC

    but note that: It only works for Amazon OpenSearch Serverless, I used the AOS cluster .

0
已接受的答案

It only works for Amazon OpenSearch Serverless, not work for AOS cluster

已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。