Overview

LlamaCloud Advanced Features provide sophisticated search and query capabilities using LlamaIndex integration. These tools enable intelligent document retrieval and answer generation from your indexed knowledge base.

Key Features

  • LLAMA_CLOUD_QUERY_WITH_LLAMA_INDEX
    • Query documents with intelligent retrieval using LlamaIndex
  • LLAMA_CLOUD_SEARCH
    • Search and generate answers using Llama Cloud index
  • LLAMA_CLOUD_SEARCH_WITH_LLAMA_INDEX
    • Enhanced search with LlamaIndex integration

Authentication

For further details, click here. To use these advanced LlamaCloud tools, you need:
  1. A LlamaCloud API key from LlamaCloud
  2. Properly configured projects and indexes
  3. Organization ID and project setup
Note: Treat API keys as sensitive information and never commit them to public repositories.

Example: Advanced Document Query System

- id: setup_query_parameters
  name: setup_query_parameters
  tool: INPUT_JSON
  input:
    - name: value
      value: {
        "queries": [
          "What are the key performance metrics mentioned in the quarterly report?",
          "How does the company's growth compare to industry benchmarks?",
          "What are the main risk factors identified?"
        ],
        "system_prompt": "You are a financial analyst. Based on the provided context, answer the following query comprehensively: {query}",
        "search_config": {
          "similarity_top_k": 5,
          "index_name": "quarterly-reports-index",
          "project_name": "financial-analysis",
          "organization_id": "your-org-id"
        }
      }

- id: query_financial_data
  name: query_financial_data
  tool: LLAMA_CLOUD_QUERY_WITH_LLAMA_INDEX
  config:
    - name: api_key
      value: "{{secrets.LLAMA_CLOUD_API_KEY}}"
  input:
    - name: input
      value: "{{steps.setup_query_parameters.result.queries}}"
    - name: system_prompt
      value: "{{steps.setup_query_parameters.result.system_prompt}}"
    - name: name
      value: "{{steps.setup_query_parameters.result.search_config.index_name}}"
    - name: project_name
      value: "{{steps.setup_query_parameters.result.search_config.project_name}}"
    - name: organization_id
      value: "{{steps.setup_query_parameters.result.search_config.organization_id}}"
    - name: similarity_top_k
      value: "{{steps.setup_query_parameters.result.search_config.similarity_top_k}}"

- id: process_query_results
  name: process_query_results
  tool: PYTHON_SANDBOX_RUN
  input:
    - name: script
      value: |
        import json
        
        # Process query results
        query_results = {{steps.query_financial_data.result}}
        processed_results = []
        
        for i, result in enumerate(query_results):
            query = result[0] if len(result) > 0 else "Unknown query"
            answer = result[1] if len(result) > 1 else "No answer provided"
            references = result[2:] if len(result) > 2 else []
            
            processed_results.append({
                "query_id": i + 1,
                "question": query,
                "answer": answer,
                "references": references,
                "reference_count": len(references)
            })
        
        # Generate summary report
        summary = {
            "total_queries": len(processed_results),
            "successful_queries": len([r for r in processed_results if r["answer"] != "No answer provided"]),
            "total_references": sum(r["reference_count"] for r in processed_results),
            "detailed_results": processed_results
        }
        
        print(json.dumps(summary, indent=2))

Example: Multi-Index Search Comparison

- id: setup_search_comparison
  name: setup_search_comparison
  tool: INPUT_JSON_WITH_VALIDATION
  input:
    - name: value
      value: {
        "search_query": "artificial intelligence trends and market outlook",
        "indexes": [
          {
            "name": "tech-reports-2024",
            "project": "technology-analysis",
            "description": "Technology industry reports and analysis"
          },
          {
            "name": "market-research-ai",
            "project": "market-intelligence", 
            "description": "AI market research and forecasts"
          }
        ],
        "organization_id": "your-org-id"
      }

- id: search_tech_reports
  name: search_tech_reports
  tool: LLAMA_CLOUD_SEARCH
  config:
    - name: api_key
      value: "{{secrets.LLAMA_CLOUD_API_KEY}}"
  input:
    - name: input
      value: ["{{steps.setup_search_comparison.result.search_query}}"]
    - name: system_prompt
      value: "Analyze the following query from a technology industry perspective: {query}"
    - name: name
      value: "{{steps.setup_search_comparison.result.indexes[0].name}}"
    - name: project_name
      value: "{{steps.setup_search_comparison.result.indexes[0].project}}"
    - name: organization_id
      value: "{{steps.setup_search_comparison.result.organization_id}}"
    - name: similarity_top_k
      value: 3

- id: search_market_intelligence
  name: search_market_intelligence
  tool: LLAMA_CLOUD_SEARCH_WITH_LLAMA_INDEX
  config:
    - name: api_key
      value: "{{secrets.LLAMA_CLOUD_API_KEY}}"
  input:
    - name: input
      value: ["{{steps.setup_search_comparison.result.search_query}}"]
    - name: system_prompt
      value: "Provide market analysis and forecasting insights for: {query}"
    - name: name
      value: "{{steps.setup_search_comparison.result.indexes[1].name}}"
    - name: project_name
      value: "{{steps.setup_search_comparison.result.indexes[1].project}}"
    - name: organization_id
      value: "{{steps.setup_search_comparison.result.organization_id}}"
    - name: similarity_top_k
      value: 3

- id: synthesize_insights
  name: synthesize_insights
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
  input:
    - name: prompt
      value: |
        Synthesize insights from multiple search results on: {{steps.setup_search_comparison.result.search_query}}
        
        Technology Industry Perspective:
        {{steps.search_tech_reports.result[0].answer}}
        
        Market Intelligence Perspective:  
        {{steps.search_market_intelligence.result[0].answer}}
        
        Create a comprehensive analysis that:
        1. Identifies common themes and trends
        2. Highlights unique insights from each source
        3. Provides actionable recommendations
        4. Notes any contradictions or differing viewpoints
        5. Suggests areas for further research
        
        Format as an executive summary with clear sections and bullet points.

Example: Contextual Information Retrieval

- id: setup_contextual_search
  name: setup_contextual_search
  tool: INPUT_TEXT
  input:
    - name: value
      value: "We are planning a new product launch in the healthcare AI sector. What regulatory considerations, market opportunities, and technical challenges should we be aware of?"

- id: extract_search_aspects
  name: extract_search_aspects
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
  input:
    - name: prompt
      value: |
        Break down this business query into specific search aspects:
        "{{steps.setup_contextual_search.result}}"
        
        Extract and categorize into:
        1. Regulatory aspects (compliance, legal, regulations)
        2. Market aspects (opportunities, competition, trends) 
        3. Technical aspects (challenges, requirements, capabilities)
        
        For each aspect, generate 2-3 specific search queries that would help gather relevant information.
        
        Return as JSON:
        {
          "regulatory_queries": ["query1", "query2", "query3"],
          "market_queries": ["query1", "query2", "query3"], 
          "technical_queries": ["query1", "query2", "query3"]
        }

- id: search_regulatory_info
  name: search_regulatory_info
  tool: LLAMA_CLOUD_QUERY_WITH_LLAMA_INDEX
  config:
    - name: api_key
      value: "{{secrets.LLAMA_CLOUD_API_KEY}}"
  input:
    - name: input
      value: "{{steps.extract_search_aspects.result.regulatory_queries}}"
    - name: system_prompt
      value: "Focus on regulatory and compliance aspects when answering: {query}"
    - name: name
      value: "regulatory-knowledge-base"
    - name: project_name
      value: "compliance-research"
    - name: organization_id
      value: "your-org-id"
    - name: similarity_top_k
      value: 4

- id: search_market_info
  name: search_market_info
  tool: LLAMA_CLOUD_QUERY_WITH_LLAMA_INDEX
  config:
    - name: api_key
      value: "{{secrets.LLAMA_CLOUD_API_KEY}}"
  input:
    - name: input
      value: "{{steps.extract_search_aspects.result.market_queries}}"
    - name: system_prompt
      value: "Provide market analysis and business intelligence for: {query}"
    - name: name
      value: "market-intelligence-index"
    - name: project_name
      value: "market-research"
    - name: organization_id
      value: "your-org-id"
    - name: similarity_top_k
      value: 4

- id: compile_comprehensive_report
  name: compile_comprehensive_report
  tool: PYTHON_SANDBOX_RUN
  input:
    - name: script
      value: |
        import json
        
        # Process all search results
        regulatory_results = {{steps.search_regulatory_info.result}}
        market_results = {{steps.search_market_info.result}}
        
        def process_results(results, category):
            processed = []
            for result in results:
                if len(result) >= 2:
                    processed.append({
                        "query": result[0],
                        "answer": result[1],
                        "references": result[2:] if len(result) > 2 else [],
                        "category": category
                    })
            return processed
        
        all_insights = []
        all_insights.extend(process_results(regulatory_results, "Regulatory"))
        all_insights.extend(process_results(market_results, "Market"))
        
        # Generate structured report
        report = {
            "executive_summary": {
                "total_insights": len(all_insights),
                "regulatory_insights": len([i for i in all_insights if i["category"] == "Regulatory"]),
                "market_insights": len([i for i in all_insights if i["category"] == "Market"])
            },
            "detailed_findings": {
                "regulatory_considerations": [i for i in all_insights if i["category"] == "Regulatory"],
                "market_opportunities": [i for i in all_insights if i["category"] == "Market"]
            },
            "action_items": [
                "Review regulatory compliance requirements",
                "Analyze market positioning strategies",
                "Assess technical implementation challenges",
                "Develop risk mitigation strategies"
            ]
        }
        
        print(json.dumps(report, indent=2))

Tips and Best Practices

  • Query Optimization: Use specific, well-structured queries for better retrieval accuracy
  • Index Management: Organize documents into logical indexes by topic or domain
  • Similarity Tuning: Adjust similarity_top_k based on the complexity of your queries
  • System Prompts: Craft specialized system prompts for different types of analysis
  • Result Processing: Always process and validate results for downstream use
  • Reference Tracking: Utilize reference information for transparency and verification
  • Batch Processing: Process multiple related queries together for efficiency
  • Context Preservation: Maintain context across multiple search operations
  • Error Handling: Implement proper error handling for API failures or empty results
  • Cost Management: Monitor API usage and optimize query patterns for cost efficiency