similarity_search.query
Performs a semantic search across one or more namespaces.Parameters
A list of one or more namespace names to search within.
The search query (text or a vector).
The maximum number of results to return. Defaults to 10.
A minimum similarity score (0-1) for results. Defaults to None.
A flag for stricter filtering. Defaults to False.
Dict[str, Any] - A dictionary containing the search results under the results key.
Raises: NamespaceNotFound, InvalidInputError.
Text search across one namespace
Search Example
Advanced Search Examples
Search across multiple namespacesMulti-Namespace Search
answer.generate
Submits a query to a text namespace to get a conversational answer generated by an LLM.Parameters
The single text namespace to search for context.
The user’s question or prompt.
Number of search results to use as context. Defaults to 5.
The identifier for the LLM to use. See Generate AI Answer for the full model list.
A list of previous conversation turns to maintain context.
The sampling temperature for the LLM (0-1). Defaults to 0.7.
Dict[str, Any] - A dictionary containing the answer, model, and other metadata.
Raises: NamespaceNotFound, InvalidInputError.
Generate Answer Example
Advanced AI Generation
Maintain conversation contextConversational AI with History
Complete Search & AI Workflow
Complete Search and AI Workflow
Search Result Structure
Search results contain the following fields:Search Result Format
AI Response Structure
AI generation responses contain:AI Response Format
Best Practices
Search Optimization
- Use specific, clear queries for better results
- Set appropriate thresholds to filter low-quality results
- Use multiple namespaces for comprehensive searches
- Consider kiosk_mode for production applications
AI Generation
- Provide clear, specific questions
- Use chat history for conversational experiences
- Adjust temperature based on creativity needs
- Choose appropriate AI models for your use case
Error Handling
Robust Search with Error Handling