Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Autogenstudio v0.1.3 exported default workflow throws AttributeError: 'dict' object has no attribute 'secrets' #3106

Closed
TheAmazingRoderic opened this issue Jul 10, 2024 · 1 comment

Comments

@TheAmazingRoderic
Copy link

Describe the bug

Exporting the default workflow and attempting to run using provided code snippet results in "AttributeError: 'dict' object has no attribute 'secrets'"

This seems to appear due to the unchecked expectation of a skills.secrets attribute in the code:

That doesn't exist in the skills portion of the export.
"skills": [
{
"user_id": "[email protected]",
"version": "0.0.1",
"name": "generate_and_save_images",
"content": "\nfrom typing ...,
"description": "Generate and save images based on a user's query.",
"libraries": [
"openai"
]
}
],

Modifying line 310 in the utils.py code from: "if skill.secrets:" to test for secrets like this: "if 'secrets' in skill.keys():" seemed to fix the issue.

Steps to reproduce

  1. Install autogenstudio v0.1.3
  2. Start UI -> autogenstudio ui --port 8081
  3. Configure model
  4. Test default workflow - success
  5. export default workflow
  6. copy application code snippet, update workflow path and execute
  7. AttributeError: 'dict' object has no attribute 'secrets'

Model Used

No response

Expected Behavior

No response

Screenshots and logs

Screenshot 2024-07-10 at 11 52 46 AM

2024-07-10 16:28:49.265 | ERROR | autogenstudio.utils.utils:load_code_execution_config:441 - Error initializing Docker executor: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

{
"name": "AttributeError",
"message": "'dict' object has no attribute 'secrets'",
"stack": "---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[8], line 7
5 # run the workflow on a task
6 task_query = "Plot the stock price of NVIDIA YTD."
----> 7 workflow_manager.run(message=task_query)

File ~/git/test/autogenstudio-v0.1.3/autogen/samples/apps/autogen-studio/autogenstudio/workflowmanager.py:386, in AutoWorkflowManager.run(self, message, history, clear_history)
376 """
377 Initiates a chat between the sender and receiver agents with an initial message
378 and an option to clear the history.
(...)
382 clear_history: If set to True, clears the chat history before initiating.
383 """
385 start_time = time.time()
--> 386 self._run_workflow(message=message, history=history, clear_history=clear_history)
387 end_time = time.time()
389 output = self._generate_output(message, self.workflow.get("summary_method", "last"))

File ~/git/test/autogenstudio-v0.1.3/autogen/samples/apps/autogen-studio/autogenstudio/workflowmanager.py:99, in AutoWorkflowManager._run_workflow(self, message, history, clear_history)
97 self.sender = self.load(agent.get("agent"))
98 elif agent.get("link").get("agent_type") == "receiver":
---> 99 self.receiver = self.load(agent.get("agent"))
100 if self.sender and self.receiver:
101 if history:

File ~/git/test/autogenstudio-v0.1.3/autogen/samples/apps/autogen-studio/autogenstudio/workflowmanager.py:272, in AutoWorkflowManager.load(self, agent)
267 raise ValueError(
268 "An agent configuration in this workflow is empty. Please provide a valid agent configuration."
269 )
271 linked_agents = agent.get("agents", [])
--> 272 agent = self.sanitize_agent(agent)
273 if agent.type == "groupchat":
274 groupchat_agents = [self.load(agent) for agent in linked_agents]

File ~/git/test/autogenstudio-v0.1.3/autogen/samples/apps/autogen-studio/autogenstudio/workflowmanager.py:249, in AutoWorkflowManager.sanitize_agent(self, agent)
247 if skills:
248 skills_prompt = ""
--> 249 skills_prompt = get_skills_from_prompt(skills, self.work_dir)
250 if agent.config.system_message:
251 agent.config.system_message = agent.config.system_message + "

" + skills_prompt

File ~/git/test/autogenstudio-v0.1.3/autogen/samples/apps/autogen-studio/autogenstudio/utils/utils.py:310, in get_skills_from_prompt(skills, work_dir)
308 prompt = "" # filename: skills.py
309 for skill in skills:
--> 310 if skill.secrets:
311 for secret in skill.secrets:
312 print(">> Secret", secret)

AttributeError: 'dict' object has no attribute 'secrets'"
}

Additional Information

No response

@TheAmazingRoderic
Copy link
Author

"Modifying line 310 in the utils.py code from: "if skill.secrets:" to test for secrets like this: "if 'secrets' in skill.keys():" seemed to fix the issue."

Update: The above had issues when the skill was a Skill. Since the issue is caused when the skill is a Dict from the json import, added check for skill being a Skill:

for skill in skills:
    if (isinstance(skill, Skill) and skill.secrets): 
        for secret in skill.secrets:
            if secret.get("value"):
                os.environ[secret["secret"]] = secret["value"]
    if not isinstance(skill, Skill):
        skill = Skill(**skill)

TheAmazingRoderic added a commit to att/autogen that referenced this issue Jul 16, 2024
victordibia added a commit that referenced this issue Jul 17, 2024
Fix for bug #3106 dict skills and test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant