šŸ” Code Extractor

function run_demo

Maturity: 44

Orchestrates a complete demonstration of an E-Ink LLM Assistant by creating three sample handwritten content files (question, instruction diagram, math problem) and processing each through an AI pipeline.

File:
/tf/active/vicechatdev/e-ink-llm/demo.py
Lines:
118 - 153
Complexity:
moderate

Purpose

This async function serves as the main entry point for demonstrating the E-Ink LLM Assistant's capabilities. It creates demo content files, processes them sequentially through an AI processing pipeline, and provides user-friendly console output showing progress and results. The function is designed to showcase the system's ability to handle handwritten content analysis and generate PDF responses.

Source Code

async def run_demo():
    """Run the complete demo"""
    print("šŸ–‹ļø  E-Ink LLM Assistant - DEMO")
    print("=" * 50)
    print("This demo will create sample handwritten content and process it with AI")
    print()
    
    # Create demo files
    print("šŸ“ Creating demo content...")
    demo_files = [
        create_handwritten_question(),
        create_instruction_diagram(), 
        create_math_problem()
    ]
    
    print(f"\nšŸš€ Processing {len(demo_files)} demo files...")
    
    # Process each demo file
    for i, demo_file in enumerate(demo_files, 1):
        print(f"\nšŸ“„ Processing demo {i}/{len(demo_files)}: {demo_file}")
        print("-" * 40)
        
        try:
            result = await process_single_file(demo_file)
            if result:
                print(f"āœ… Success! Response saved as: {Path(result).name}")
            else:
                print(f"āŒ Failed to process {demo_file}")
        except Exception as e:
            print(f"āŒ Error: {e}")
    
    print(f"\nšŸŽ‰ Demo complete!")
    print(f"šŸ“ Check the current directory for:")
    print(f"   • Original demo files: demo_*.png")
    print(f"   • AI responses: RESPONSE_*.pdf")
    print(f"\nšŸ’” Try opening the PDF responses to see the AI analysis!")

Return Value

Returns None (implicitly). The function produces side effects including: console output showing demo progress, creation of demo PNG files (demo_*.png), and generation of AI response PDF files (RESPONSE_*.pdf) in the current directory.

Dependencies

  • asyncio
  • sys
  • pathlib
  • PIL
  • processor

Required Imports

import asyncio
import sys
from pathlib import Path
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from processor import process_single_file

Usage Example

import asyncio
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
from processor import process_single_file

# Ensure helper functions are defined:
# create_handwritten_question(), create_instruction_diagram(), create_math_problem()

async def main():
    await run_demo()

if __name__ == '__main__':
    asyncio.run(main())

Best Practices

  • Must be called within an async context using 'asyncio.run()' or 'await'
  • Ensure all three demo creation functions (create_handwritten_question, create_instruction_diagram, create_math_problem) are defined before calling
  • Verify write permissions in the current directory before execution
  • Handle exceptions at the caller level as the function catches and logs errors internally but continues processing
  • The function processes files sequentially; for production use, consider parallel processing for better performance
  • Check that the 'processor' module and its dependencies are properly configured with necessary API keys
  • Monitor disk space as the function creates multiple image and PDF files

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function main_v59 81.9% similar

    Orchestrates a comprehensive demonstration of E-Ink LLM hybrid mode capabilities, running three sequential demos showcasing graphics generation, placeholder parsing, and complete hybrid response processing.

    From: /tf/active/vicechatdev/e-ink-llm/demo_hybrid_mode.py
  • function run_tests 72.2% similar

    Asynchronous test suite function that creates test images with various text prompts, processes them through an E-Ink LLM processor, and reports usage statistics and results.

    From: /tf/active/vicechatdev/e-ink-llm/test.py
  • function main_v68 70.1% similar

    Async entry point for an E-Ink LLM Assistant that processes handwritten/drawn content using AI vision models, supporting local files, reMarkable Cloud, and OneDrive integration.

    From: /tf/active/vicechatdev/e-ink-llm/main.py
  • function main_v75 64.4% similar

    Asynchronous test runner function that executes a suite of tests for the E-Ink LLM Assistant application, including tests for compact formatting, session management, and improvement comparisons.

    From: /tf/active/vicechatdev/e-ink-llm/test_improvements.py
  • function main_v73 64.2% similar

    Orchestrates and executes a series of example demonstrations for the DocChat system, including document indexing, RAG queries, and conversation modes.

    From: /tf/active/vicechatdev/docchat/example_usage.py
← Back to Browse