PageIndex icon indicating copy to clipboard operation
PageIndex copied to clipboard

Feat: Add multi-provider LLM support (OpenAI + Gemini)

Open dzakwanalifi opened this issue 2 months ago • 0 comments

Problem

PageIndex currently only supports OpenAI models, limiting user choice and potentially increasing costs.

Solution

Add unified interface supporting both OpenAI GPT-4 and Gemini 2.5 Flash models with structured output capabilities.

Key Changes

  • Add LLM provider abstraction layer in utils.py
  • Support structured output with Pydantic models for Gemini
  • Add provider configuration in config.yaml
  • Fix JSON parsing error handling in page_index.py
  • Update function signatures for better model parameter handling

Code Changes

  • utils.py: Added LLMProvider class with unified interface
  • config.yaml: Added provider configuration option
  • page_index.py: Enhanced error handling and Gemini integration

Use Case

Users can now choose between providers:

# OpenAI (default)
python run_pageindex.py --pdf_path doc.pdf

# Gemini
python run_pageindex.py --pdf_path doc.pdf --provider gemini

This provides flexibility for different cost/performance requirements while maintaining full compatibility.

dzakwanalifi avatar Oct 24 '25 06:10 dzakwanalifi