search_agent_context
async
¶
search_agent_context(
agent_context_id: AgentContextIdentifier,
query: SearchQuery,
search_type: SearchAgentContextType,
*,
config_overrides: Optional[AsyncContextClientConfig] = None,
max_results: Optional[int] = None,
next_token: Optional[str] = None,
filter: Optional[SearchFilter] = None,
) -> SearchAgentContextResponse
Searches an agent context for entities matching a query. Returns ranked entities with relevance scores and metadata. To see the edges around a result node, pass its node ID to TraverseAgentContext.
Parameters:
-
max_results(Optional[int], default:None) –Maximum number of results to return per page.
-
next_token(Optional[str], default:None) –Opaque continuation token from a prior response. Omit on the first page.
-
agent_context_id(AgentContextIdentifier) –The agent context to search, by ID or full Amazon Resource Name (ARN).
-
query(SearchQuery) –The natural-language query or keywords to search for in the agent context. AWS Context interprets it based on
searchType: as literal text forKEYWORD, as a semantic concept forSEMANTIC, or as both forAUTO. -
filter(Optional[SearchFilter], default:None) –Optional filter on node attributes: a single comparison, or
andAllof comparisons that must all match. -
search_type(SearchAgentContextType) –The search strategy to use. Valid values:
-
KEYWORD- Full-text keyword matching (BM25). -
SEMANTIC- Vector similarity of embeddings. -
AUTO- Keyword matches first, then semantic matches for the remaining results.
-
Raises:
-
AccessDeniedException–You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.
-
InternalServerException–The request failed because of an internal error. Retry the request.
-
ThrottlingException–The request was denied because it exceeded a request rate quota. Wait, then retry the request.
-
ValidationException–The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.
-
ConflictException–The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.
-
ResourceNotFoundException–The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Search an agent context The following example runs a semantic search for customer orders and returns the two best-matching nodes, an AWS Glue table and one of its columns.
>>> await client.search_agent_context(agent_context_id='ac-0123456789abcdef0123456789abcdef', query='customer orders', search_type='SEMANTIC', max_results=5)
Source code in docs_src/capo_context/_services/async_context.py
3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 | |