run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
36.71k stars 5.26k forks source link

[Bug]: validation error for LLMRerank llm value is not a valid dict (type=type_error.dict) #16960

Open Kitdit opened 6 hours ago

Kitdit commented 6 hours ago

Bug Description

llamaindex version=0.10.68 baseurl and bearertoke

Version

0.10.68

Steps to Reproduce

using llmrerank

Relevant Logs/Tracbacks

No response

dosubot[bot] commented 6 hours ago

I found a similar open issue regarding the validation error for LLMRerank where the llm value is not recognized as a valid dictionary. The issue suggests that the llm parameter should be an instance of the LLM class, not a dictionary or any other type. Here's a suggested solution:

Ensure that the llm parameter is correctly initialized as an instance of the LLM class. For example, using the OpenAI class:

from llama_index.llms.openai import OpenAI

reranker = LLMRerank(
    choice_batch_size=5, 
    top_n=reranker_top_n, 
    llm=OpenAI(model="gpt-4o")
)

Make sure to replace OpenAI(model="gpt-4o") with the actual initialization of your LLM instance. This setup should resolve the validation error [1].

Additionally, if you are using a dictionary to define the llm, ensure it includes a valid "class_name" key that matches one of the recognized LLMs, such as "OpenAI", "HuggingFaceLLM", etc. [2].

To continue talking to Dosu, mention @dosu.

logan-markewich commented 6 hours ago

@Kitdit you've given no code to reproduce. Seems like you did not pass in a valid llm into llm rerank

Dosu gave a great example

Kitdit commented 5 hours ago

@Kitdit you've given no code to reproduce. Seems like you did not pass in a valid llm into llm rerank

Dosu gave a great example

Here is the code reranker = LLMRerank( choice_batch_size=5, top_n=reranker_top_n, llm=Settings.llm )

Dosu code does not work