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

promote Dev #105

Merged
merged 29 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
130d579
Capability to load skills from external location
Aug 26, 2024
b501540
readme instructions for ADDITIONAL_SKILL_DIRS env var
Aug 28, 2024
5c8c527
avoid warning on additional skills
Sep 6, 2024
01ddb7d
bug fix
deepak-akkil Sep 6, 2024
14f55a8
Merge pull request #99 from EmergenceAI/fix_test_processor_config
deepak-akkil Sep 6, 2024
102d8ca
Windows-specific commands for running server locally
danielkornev Sep 7, 2024
d21f667
first version of loop detection
deepak-akkil Sep 10, 2024
b0e99ad
minor change in return statement
deepak-akkil Sep 10, 2024
ec1d0b9
Make LLM config available in API route
deepak-akkil Sep 10, 2024
096a4c8
Merge pull request #100 from danielkornev/patch-1
deepak-akkil Sep 10, 2024
d1e04ef
do not open the url, if browser already in it
deepak-akkil Sep 10, 2024
9035f88
config for allowing planner to have user input
Sep 10, 2024
0c15f6e
Updates to make LLM config dict[str,Any]
deepak-akkil Sep 11, 2024
51ac2d8
clean up print statements
deepak-akkil Sep 11, 2024
54c6256
Update README.md
deepak-akkil Sep 11, 2024
0a57d03
linting
Sep 11, 2024
9c69db6
remove unneeded import
Sep 11, 2024
5c45327
Merge pull request #102 from EmergenceAI/llm-config-in-api-route
teaxio Sep 11, 2024
df8a745
linting
Sep 12, 2024
f0365df
Merge pull request #101 from EmergenceAI/loop_detection
teaxio Sep 12, 2024
c24c6e9
max chat rounds for planner and browser nav agents
Sep 12, 2024
5228dc4
detect if ran out of turns and send a message about it
Sep 15, 2024
6e79ac9
Merge pull request #103 from EmergenceAI/max_chat_rounds
teaxio Sep 16, 2024
14653e1
bug fix regarding saving planner chatter
deepak-akkil Sep 16, 2024
54b6081
Merge branch 'dev' of https://github.com/EmergenceAI/Agent-E into dev
deepak-akkil Sep 16, 2024
80ef975
bug fix regarding saving planner chatter in api route
deepak-akkil Sep 16, 2024
c888423
incorrect instructions in readme
Sep 16, 2024
fed2962
typo
Sep 16, 2024
7f48ba6
Ability to enable more verbose logging for openai and autogen
Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Capability to load skills from external location
  • Loading branch information
teaxio committed Aug 26, 2024
commit 130d579206a5759d34b204874e2c0a20b8cc240e
63 changes: 45 additions & 18 deletions ae/core/agents/browser_nav_agent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import importlib
import os
from datetime import datetime
from string import Template
from typing import Any
Expand All @@ -18,6 +20,7 @@

#from ae.core.skills.pdf_text_extractor import extract_text_from_pdf
from ae.core.skills.press_key_combination import press_key_combination
from ae.core.skills.skill_registry import skill_registry
from ae.utils.logger import logger


Expand Down Expand Up @@ -73,44 +76,30 @@ def __register_skills(self):
Register all the skills that the agent can perform.
"""

# Register openurl skill for LLM by assistant agent
# Register each skill for LLM by assistant agent and for execution by user_proxy_agen

self.agent.register_for_llm(description=LLM_PROMPTS["OPEN_URL_PROMPT"])(openurl)
# Register openurl skill for execution by user_proxy_agent
self.browser_nav_executor.register_for_execution()(openurl)

# Register enter_text_and_click skill for LLM by assistant agent
# self.agent.register_for_llm(description=LLM_PROMPTS["ENTER_TEXT_AND_CLICK_PROMPT"])(enter_text_and_click)
# Register enter_text_and_click skill for execution by user_proxy_agent
# self.browser_nav_executor.register_for_execution()(enter_text_and_click)

# Register get_dom_with_content_type skill for LLM by assistant agent
self.agent.register_for_llm(description=LLM_PROMPTS["GET_DOM_WITH_CONTENT_TYPE_PROMPT"])(get_dom_with_content_type)
# Register get_dom_with_content_type skill for execution by user_proxy_agent
self.browser_nav_executor.register_for_execution()(get_dom_with_content_type)

# Register click_element skill for LLM by assistant agent
self.agent.register_for_llm(description=LLM_PROMPTS["CLICK_PROMPT"])(click_element)
# Register click_element skill for execution by user_proxy_agent
self.browser_nav_executor.register_for_execution()(click_element)

# Register geturl skill for LLM by assistant agent
self.agent.register_for_llm(description=LLM_PROMPTS["GET_URL_PROMPT"])(geturl)
# Register geturl skill for execution by user_proxy_agent
self.browser_nav_executor.register_for_execution()(geturl)

# Register bulk_enter_text skill for LLM by assistant agent
self.agent.register_for_llm(description=LLM_PROMPTS["BULK_ENTER_TEXT_PROMPT"])(bulk_enter_text)
# Register bulk_enter_text skill for execution by user_proxy_agent
self.browser_nav_executor.register_for_execution()(bulk_enter_text)

# Register entertext skill for LLM by assistant agent
self.agent.register_for_llm(description=LLM_PROMPTS["ENTER_TEXT_PROMPT"])(entertext)
# Register entertext skill for execution by user_proxy_agent
self.browser_nav_executor.register_for_execution()(entertext)

# Register entertext skill for LLM by assistant agent
self.agent.register_for_llm(description=LLM_PROMPTS["PRESS_KEY_COMBINATION_PROMPT"])(press_key_combination)
# Register entertext skill for execution by user_proxy_agent
self.browser_nav_executor.register_for_execution()(press_key_combination)

self.agent.register_for_llm(description=LLM_PROMPTS["EXTRACT_TEXT_FROM_PDF_PROMPT"])(extract_text_from_pdf)
Expand All @@ -129,5 +118,43 @@ def __register_skills(self):
config={"callback": None},
)
'''
# print(f">>> Function map: {self.browser_nav_executor.function_map}") # type: ignore
# print(">>> Registered skills for BrowserNavAgent and BrowserNavExecutorAgent")
self.__load_additional_skills()

#print(f">>> Function map: {self.browser_nav_executor.function_map}") # type: ignore


def __load_additional_skills(self):
"""
Dynamically load additional skills from directories or specific Python files
specified by an environment variable.
"""
# Get additional skill directories or files from environment variable
additional_skill_paths: list[str] = os.getenv('ADDITIONAL_SKILL_DIRS', "").split(',')

for skill_path in additional_skill_paths:
skill_path = skill_path.strip() # Strip whitespace

if os.path.isdir(skill_path):
# If the path is a directory, process all .py files in it
for filename in os.listdir(skill_path):
if filename.endswith(".py"):
module_name = filename[:-3] # Remove .py extension
module_path = f"{skill_path.replace('/', '.')}.{module_name}"
importlib.import_module(module_path)

elif skill_path.endswith(".py") and os.path.isfile(skill_path):
# If the path is a specific .py file, load it directly
module_name = os.path.basename(skill_path)[:-3] # Strip .py extension
directory_path = os.path.dirname(skill_path).replace('/', '.')
module_path = f"{directory_path}.{module_name}"
importlib.import_module(module_path)

else:
logger.warning(f"Invalid skill path specified: {skill_path}")

# Register the skills that were dynamically discovered
for skill in skill_registry:
self.agent.register_for_llm(description=skill['description'])(skill['func'])
self.browser_nav_executor.register_for_execution()(skill['func'])
logger.debug(f"Registered additional skill: {skill['name']}")

29 changes: 29 additions & 0 deletions ae/core/skills/skill_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# skill_registry.py
from collections.abc import Callable
from typing import Any

# Define the type of the functions that will be registered as skills
SkillType = Callable[..., Any]

# Global registry to store private skill functions and their metadata
skill_registry: list[dict[str, Any]] = []

def skill(description: str, name: str|None = None) -> Callable[[SkillType], SkillType]:
"""
Decorator for registering private skills.

Parameters:
- description: A string describing the skill's function.
- name: Optional name to register the skill with. If not provided, the function's name will be used.

Returns:
- A decorator function that registers the skill in the global registry.
"""
def decorator(func: SkillType) -> SkillType:
skill_registry.append({
"name": name if name else func.__name__, # Use provided name or fallback to function name
"func": func,
"description": description
})
return func
return decorator