AGiXT icon indicating copy to clipboard operation
AGiXT copied to clipboard

Error adding agent: module provider has no attribute gpt4free

Open birdup000 opened this issue 2 years ago • 5 comments

Description

When I click add add agent it says "Error adding agent: module provider has no attribute gpt4free" using docker

Steps to Reproduce the Bug

1.Go to Agent Settings 2.Enter any name to create a new Agent 3.Hit Add Agent 4.Error will spit out

Expected Behavior

When clicking Add Agent it should add the Agent.

Actual Behavior

It spits out the error "Error adding agent: module provider has no attribute gpt4free"

Additional Context / Screenshots

image

Inside the Docker instance inside the app in the agents folder it has created the agent name with a config.json file image image

Operating System

  • [ ] Microsoft Windows
  • [ ] Apple MacOS
  • [X] Linux
  • [ ] Android
  • [ ] iOS
  • [ ] Other

Python Version

  • [ ] Python <= 3.9
  • [X] Python 3.10
  • [ ] Python 3.11

Environment Type - Connection

  • [X] Local
  • [X] Remote

Environment Type - Container

  • [X] Using Docker
  • [x] Not Using Docker

Acknowledgements

  • [X] My issue title is concise, descriptive, and in title casing.
  • [X] I have searched the existing issues to make sure this bug has not been reported yet.
  • [X] I am using the latest version of AGiXT.
  • [X] I have provided enough information for the maintainers to reproduce and diagnose the issue.

birdup000 avatar May 22 '23 01:05 birdup000

@localagi This seems to be happening only in docker :( I was wondering if you could also take a look at this too?

birdup000 avatar May 22 '23 02:05 birdup000

The problem is happening because we set gpt4free as default for some configs like this in the agent.py

                agent_config_data["settings"] = {
                    "provider": "gpt4free",
                    "AI_MODEL": "gpt-4",
                    "AI_TEMPERATURE": "0.7",
                    "MAX_TOKENS": "4000",
                    "embedder": "default",
                }

The error pops here

class Provider:
    def __init__(self, name, **kwargs):
        try:
            module = importlib.import_module(f".{name}", package=__name__)
            provider_class = getattr(module, f"{name.capitalize()}Provider")
            self.instance = provider_class(**kwargs)

            # Install the requirements if any
            self.install_requirements()

        except (ModuleNotFoundError, AttributeError) as e:
            raise AttributeError(f"module {__name__} has no attribute {name}") from e

Removing the try/except we see the real error:

agent-llm-fork-backend-1  |   File "/app/provider/gpt4free.py", line 1, in <module>
agent-llm-fork-backend-1  |     import gpt4free
agent-llm-fork-backend-1  |   File "/usr/local/lib/python3.10/site-packages/gpt4free/__init__.py", line 6, in <module>
agent-llm-fork-backend-1  |     from gpt4free import usesless
agent-llm-fork-backend-1  |   File "/usr/local/lib/python3.10/site-packages/gpt4free/usesless/__init__.py", line 9, in <module>
agent-llm-fork-backend-1  |     from password_generator import PasswordGenerator
agent-llm-fork-backend-1  | ModuleNotFoundError: No module named 'password_generator'

gpt4free lib is broken. They added a new dependency but its not in theirs requirements.txt Guess we should change the default config provider. Or, better yet, remove the default e force user to fill those infos

lgwacker avatar May 22 '23 03:05 lgwacker

Yep just tested in manual with streamlit same issue :(

birdup000 avatar May 22 '23 04:05 birdup000

same issue

ychy00001 avatar May 22 '23 06:05 ychy00001

The correct dependency to pip install is random-password-generator. if you installed password_generator, remove it and try again.

Edit: dependency was added to the requirements

its-ven avatar May 22 '23 13:05 its-ven

Seems like I don't see this particular error anymore ;)

birdup000 avatar May 23 '23 00:05 birdup000