Skip to content

Conversation

@anistark
Copy link
Member

@anistark anistark commented Oct 24, 2025

Consolidates dual LLM factories into a single, explicit llm_factory() API. Removes instructor_llm_factory() entirely.

Changes

Core Changes

  • Unified llm_factory(): Single factory supporting multiple LLM providers (OpenAI, Anthropic, Cohere, Google, LiteLLM)

    • Requires explicit parameters: model, provider, client
    • Returns: InstructorBaseRagasLLM (structured outputs only)
    • Clear error messages for missing parameters
  • Removed instructor_llm_factory(): Deleted entirely (~97 lines)

    • Functionality merged into unified llm_factory()
    • Removed from public exports

API Change

Before:

from ragas.llms import instructor_llm_factory
llm = instructor_llm_factory("openai", model="gpt-4o", client=client)

After:

from ragas.llms import llm_factory
llm = llm_factory("gpt-4o", client=client)  # provider defaults to "openai"

Migration for Users

# Old code
llm = llm_factory("gpt-4o-mini")

# Error message:
# ValueError: llm_factory() requires a client instance.
# Text-only mode has been removed.

# To migrate:
from openai import OpenAI
client = OpenAI(api_key='...')
llm = llm_factory('gpt-4o-mini', client=client)

Notes

This is a breaking change for the public API, but justified because:

  1. Old text-only factory was already deprecated
  2. All new metrics require structured outputs (InstructorLLM)
  3. Unified API is simpler and more maintainable
  4. Clear error messages guide easy migration

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. size:XL This PR changes 500-999 lines, ignoring generated files. labels Oct 24, 2025
@anistark anistark force-pushed the refactor/llm-factory branch from b79406a to e5985d3 Compare October 24, 2025 13:03
@anistark anistark changed the title refactor: instructor_llm_factory merge with llm_factory refactor: instructor_llm_factory merge with llm_factory Oct 24, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 24, 2025
@anistark anistark merged commit 34b4733 into explodinggradients:main Oct 25, 2025
9 checks passed
@anistark anistark deleted the refactor/llm-factory branch October 25, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant