run-llama / llama_index

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

[Bug]: ValueError: Failed to find python package for class MixtureOfAgentsPack #14265

Open efenocchi opened 1 month ago

efenocchi commented 1 month ago

Bug Description

Hi @ravi03071991, I tried to download the Mixture-Of-Agents package but got the following error:

raise ValueError(f"Failed to find python package for class {llama_pack_class}")
ValueError: Failed to find python package for class MixtureOfAgents

Version

0.10.47

Steps to Reproduce

run llamaindex-cli download-llamapack MixtureOfAgentsPack --download-dir ./mixture_of_agents_pack or try downloading the package from code

Relevant Logs/Tracbacks

No response

dosubot[bot] commented 1 month ago

Hey @efenocchi! 👋 I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer. Let's tackle this together!

To resolve the error "Failed to find python package for class MixtureOfAgents" when trying to download the Mixture-Of-Agents package using the llamaindex-cli, ensure that you are using the correct package name and import statements. The correct usage should be:

  1. Download the Mixture-Of-Agents pack using the llamaindex-cli:
llamaindex-cli download-llamapack MixtureOfAgentsPack --download-dir ./mixture_of_agents_pack
  1. Use the following code to import and utilize the Mixture-Of-Agents pack:
from llama_index.core.llama_pack import download_llama_pack

# Download and install dependencies
MixtureOfAgentsPack = download_llama_pack(
    "MixtureOfAgentsPack", "./mixture_of_agents_pack"
)

from llama_index.llms.openai import OpenAI
from llama_index.llms.mistralai import MistralAI

# Add OPENAI_API_KEY and MISTRAL_API_KEY to your environment variables

mixture_of_agents_pack = MixtureOfAgentsPack(
    llm=OpenAI(model="gpt-4"),  # Aggregator
    reference_llms=[
        OpenAI(model="gpt-3.5-turbo"),
        MistralAI(model="mistral-medium"),
    ],  # Proposers
    num_layers=3,
    temperature=0.1,
)

# Use the pack
response = mixture_of_agents_pack.run("What is LlamaIndex?")

Make sure your code reflects these steps and import statements. If you are using MixtureOfAgents instead of MixtureOfAgentsPack, you need to update your code to use MixtureOfAgentsPack [1][2].

To continue talking to Dosu, mention @dosu.

efenocchi commented 1 month ago

I looked at some example notebooks from other LlamaPacks and found this temporary solution (but the pip install command is nowhere)

pip install llama-index-packs-mixture-of-agents

from llama_index.packs.mixture_of_agents import MixtureOfAgentsPack
...
ravi03071991 commented 1 month ago

@efenocchi Thanks for pointing it out. I will update the readme.

Yeah, pip install llama-index-packs-mixture-of-agents should ideally work.

efenocchi commented 1 month ago

@ravi03071991 Thank you!

efenocchi commented 1 month ago

Hi @ravi03071991, I saw your PR, be careful that this doesn't solve the problem.

The errors are here: llamaindex-cli download-llamapack MixtureOfAgentsPack --download-dir ./mixture_of_agents_pack

and here:

from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
MixtureOfAgentsPack = download_llama_pack(
    "MixtureOfAgentsPack", "./mixture_of_agents_pack"
)

The solution is: 1) install the package with pip install llama-index-packs-mixture-of-agents 2) call it directly from llama_index.packs.mixture_of_agents:

from llama_index.packs.mixture_of_agents import MixtureOfAgentsPack
from llama_index.llms.openai import OpenAI
from llama_index.llms.mistralai import MistralAI

# Add OPENAI_API_KEY and MISTRAL_API_KEY to your env variable

mixture_of_agents_pack = MixtureOfAgentsPack(
    llm=OpenAI(model="gpt-4"),  # Aggregator
    reference_llms=[
        OpenAI(model="gpt-3.5-turbo"),
        MistralAI(model="mistral-medium"),
    ],  # Proposers
    num_layers=3,
    temperature=0.1,
)
response = mixture_of_agents_pack.run("What is LlamaIndex?")
logan-markewich commented 1 month ago

the download syntax is very annoying to maintain -- we need a better way to manage it I think

guptadhaval18 commented 2 weeks ago

Hi @logan-markewich, have anything in mind? Would like to work on this task. Else can send a simple fix for by updating given mapping/