Repository: explodinggradients/ragas
Issue: llm_factory fails during aevaluate with AttributeError
Root cause: Interface Contract Mismatch

- [x] I have checked the [documentation](https://docs.ragas.io/) and related resources and couldn't resolve my bug.

**Describe the bug**

When using `llm_factory` with `AsyncOpenAI` client and `AnswerCorrectness` metric, the evaluation fails with `AttributeError: 'InstructorLLM' object has no attribute 'agenerate_prompt'`. The metric returns `NaN` values instead of proper scores.

The same setup works correctly when using `LangchainLLMWrapper` with `ChatOpenAI`, but we want to use the recommended `llm_factory` approach with `AsyncOpenAI` for better async performance.

**Ragas version:** 0.3.9

**Python version:** 3.13.0

**Code to Reproduce**

```python
import asyncio
import os
import pandas as pd
from datasets import Dataset
from openai import AsyncOpenAI
from ragas import aevaluate
from ragas.llms import llm_factory
from ragas.embeddings.base import embedding_factory
from ragas.metrics import AnswerCorrectness

async def example_failing_with_llm_factory():
    """This fails - using AsyncOpenAI with llm_factory"""
    # Create sample dataset
    df = pd.DataFrame({
        "question": ["When was the first Super Bowl held?"],
        "answer": ["It was held on January 15th, 1967."],
        "reference": ["The first Super Bowl took place on January 15, 1967."],
        "contexts": [["The first Super Bowl took place on January 15, 1967."]],
    })
    dataset = Dataset.from_dict({
        "question": df["question"].tolist(),
        "answer": df["answer"].tolist(),
        "reference": df["reference"].tolist(),
        "contexts": df["contexts"].tolist(),
    })

    # Create AsyncOpenAI client
    client = AsyncOpenAI()

    # Create LLM using llm_factory (as recommended in docs)
    llm = llm_factory("gpt-4o-mini", client=client, temperature=0, seed=42)

    # Create embeddings (AnswerCorrectness requires embeddings with llm_factory)
    embeddings = embedding_factory(
        provider="openai",
        model="text-embedding-3-small",
        client=client,
    )

    # AnswerCorrectness requires both llm and embeddings when using llm_factory
    answer_correctness = AnswerCorrectness(llm=llm, embeddings=embeddings)

    # This fails with AttributeError
    result = await aevaluate(
        dataset,
        metrics=[answer_correctness],
        llm=llm,
    )

    # Print results to show NaN values
    result_df = result.to_pandas()
    print("Result DataFrame:")
    print(result_df.to_string())
    print(f"\nanswer_correctness value: {result_df['answer_correctness'].iloc[0]}")
    print(f"Is NaN: {pd.isna(result_df['answer_correctness'].iloc[0])}")

    return result

if __name__ == "__main__":
    # Set OPENAI_API_KEY environment variable before running
    asyncio.run(example_failing_with_llm_factory())
```

**Error trace**

The error is caught internally during evaluation and logged as:

```
Exception raised in Job[0]: AttributeError('InstructorLLM' object has no attribute 'agenerate_prompt')
```

The evaluation completes without raising an exception, but the resulting DataFrame shows `answer_correctness` as `NaN` instead of a numeric score. The error occurs because `InstructorLLM` (used internally by `llm_factory`) doesn't implement the `agenerate_prompt` method that `AnswerCorrectness` metric expects.

**Expected behavior**

The `llm_factory` approach with `AsyncOpenAI` should work the same way as `LangchainLLMWrapper` with `ChatOpenAI`. The `AnswerCorrectness` metric should:

1. Successfully evaluate the dataset without errors
2. Return proper numeric scores (not NaN) for the `answer_correctness` metric

**Additional context**

- The same code works perfectly when using `LangchainLLMWrapper(ChatOpenAI(...))` instead of `llm_factory`
- We're using `ragas>=0.3.9,<0.4.0` as specified in requirements
- I have must missed something since this seems like quite basic example. However, I checked the docs and the code seems correct :) 


<!-- PS: bugs suck but is also part of the process. We sincerely apologies for breaking your flow because of it, but don't worry, we got your back ❤️. We will get this fixed as fast as we can and thanks for helping us out by reporting it 🙏. -->


Interesting that the issue is opened just an hour ago. Hopefully it gets resolved by tomorrow.

@pavel-blagodov try with the new metrics collections:

```py
from ragas.metrics.collections import AnswerCorrectness
```


@anistark ,

Thank you. The Metrics imported via ragas.metrics.collections do work 🙌 .