Skip to content

AttributeError: 'InstructorLLM' object has no attribute 'agenerate_prompt' #2383

@02hao09

Description

@02hao09

[ ] I have checked the documentation and related resources and couldn't resolve my bug.

Describe the bug
AttributeError: 'InstructorLLM' object has no attribute 'agenerate_prompt'

Ragas version: 0.3.7
Python version: 3.10

Code to Reproduce
from ragas.llms.base import instructor_llm_factory, llm_factory, InstructorLLM
from ragas.embeddings import OpenAIEmbeddings

初始化 Azure OpenAI Client

azure_client = AzureOpenAI(
api_key=api_key,
api_version=api_version,
azure_endpoint=api_base
)

建立 RAGAS 可用的 LLM

llm = instructor_llm_factory(provider="openai",model="gpt-4o", client=azure_client)
#lm = llm_factory(model="gpt-4o")

embeddings = OpenAIEmbeddings(
model="text-embedding-ada-002",
client=azure_client
)

import asyncio
async def main():
context_precision_adapted_prompts = await context_precision.adapt_prompts(language="chinese", llm=llm)
print(context_precision_adapted_prompts)
asyncio.run(main())
print(context_precision)

Error trace

File "/myapps/test.py", line 40, in
asyncio.run(main())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "/myapps/test.py", line 38, in main
context_precision_adapted_prompts = await context_precision.adapt_prompts(language="chinese", llm=llm)
File "/usr/local/lib/python3.10/site-packages/ragas/prompt/mixin.py", line 78, in adapt_prompts
adapted_prompt = await prompt.adapt(language, llm, adapt_instruction)
File "/usr/local/lib/python3.10/site-packages/ragas/prompt/pydantic_prompt.py", line 330, in adapt
translated_strings = await translate_statements_prompt.generate(
File "/usr/local/lib/python3.10/site-packages/ragas/prompt/pydantic_prompt.py", line 164, in generate
output_single = await self.generate_multiple(
File "/usr/local/lib/python3.10/site-packages/ragas/prompt/pydantic_prompt.py", line 234, in generate_multiple
resp = await langchain_llm.agenerate_prompt(
AttributeError: 'InstructorLLM' object has no attribute 'agenerate_prompt'

Expected behavior
context_precision.adapt_prompts(language="chinese", llm=llm) converts PROMPT into Chinese.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    answered🤖 The question has been answered. Will be closed automatically if no new commentsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions