Error adding agent: module provider has no attribute gpt4free
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
Inside the Docker instance inside the app in the agents folder it has created the agent name with a config.json file
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.
@localagi This seems to be happening only in docker :( I was wondering if you could also take a look at this too?
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
Yep just tested in manual with streamlit same issue :(
same issue
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
Seems like I don't see this particular error anymore ;)