Skip to content

Add fallback model for DSPy inference#70

Merged
Miyamura80 merged 8 commits into
mainfrom
dspy-fallback
Jan 26, 2026
Merged

Add fallback model for DSPy inference#70
Miyamura80 merged 8 commits into
mainfrom
dspy-fallback

Conversation

@Miyamura80

Copy link
Copy Markdown
Owner

Summary

  • add fallback model configuration to default LLM settings
  • initialize a secondary DSPy LM and switch on ServiceUnavailableError
  • retry primary calls as before and fall back with logging

Testing

  • make test_fast

@greptile-apps

greptile-apps Bot commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Added fallback model support to DSPy inference with automatic failover on service unavailability and rate limit errors.

  • Added fallback_model field to DefaultLlm config model
  • Configured gemini-2.5-flash as fallback for gemini-3-flash primary model
  • Refactored LM initialization into _build_lm() helper method for reuse
  • Implemented retry logic for both RateLimitError and ServiceUnavailableError
  • Added fallback mechanism that switches to secondary model when primary fails after retries
  • Enhanced error logging to distinguish between primary and fallback failures
  • Properly guards against initializing fallback when same as primary or None

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation properly handles fallback model initialization with correct null checks, implements structured error handling with appropriate logging, and maintains backward compatibility. Previous thread issues about null checks and extra parentheses appear to have been addressed in subsequent commits. The code follows project style guides for logging.
  • No files require special attention

Important Files Changed

Filename Overview
common/config_models.py Added optional fallback_model field to DefaultLlm config model - simple, safe schema change
common/global_config.yaml Updated default model to gemini-3-flash and added gemini-2.5-flash as fallback - verify model names exist
utils/llm/dspy_inference.py Implemented fallback LM with retry logic for RateLimitError and ServiceUnavailableError - well-structured error handling

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread utils/llm/dspy_inference.py Outdated

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread utils/llm/dspy_inference.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread utils/llm/dspy_inference.py Outdated
Comment thread utils/llm/dspy_inference.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread utils/llm/dspy_inference.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@Miyamura80 Miyamura80 merged commit 9acd097 into main Jan 26, 2026
8 checks passed
@github-actions github-actions Bot deleted the dspy-fallback branch January 26, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant