This repository has been archived by the owner on Jun 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57907bc
commit 2dc1a0a
Showing
13 changed files
with
1,644 additions
and
80 deletions.
There are no files selected for viewing
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"2023-08-14 08:16:00+00:00": {} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"2023-09-01 08:13:53+00:00": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"2023-08-14 08:13:00+00:00": {}, | ||
"2023-08-14 17:10:00+00:00": {}, | ||
"2023-08-20 08:13:26+00:00": {}, | ||
"2023-08-24 03:24:34+00:00": {}, | ||
"2023-08-31 15:33:52+00:00": {}, | ||
"2023-09-01 08:13:39+00:00": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"2023-08-14 08:13:00+00:00": {}, | ||
"2023-08-14 08:37:00+00:00": {}, | ||
"2023-08-14 09:48:00+00:00": {}, | ||
"2023-08-31 15:34:10+00:00": {}, | ||
"2023-09-01 08:13:31+00:00": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"2023-08-31 15:25:08+00:00": {}, | ||
"2023-08-31 15:33:23+00:00": {}, | ||
"2023-09-01 08:13:11+00:00": {}, | ||
"2023-09-01 15:37:02+00:00": {}, | ||
"2023-09-01 16:08:58+00:00": {}, | ||
"2023-09-01 17:17:30+00:00": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"2023-08-30 23:11:52+00:00": {}, | ||
"2023-08-31 15:35:06+00:00": {}, | ||
"2023-09-01 08:13:41+00:00": {}, | ||
"2023-09-01 17:05:12+00:00": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,220 @@ | ||
import re | ||
import json | ||
|
||
|
||
def is_action_auto_gpt(log): | ||
"""AutoGPTs actions are defined by the presence of the "command" key.""" | ||
return bool(re.search(r'"command"\s*:', log)) | ||
"""AutoGPTs actions are defined by the presence of the "command" key. | ||
World state actions | ||
- web_search | ||
- write_to_file | ||
- browse_website | ||
- execute_python_file | ||
- list_files | ||
Internal actions | ||
- goals_accomplished | ||
"""Other notes | ||
Performing actions | ||
- web_search | ||
- write_to_file | ||
- browse_website | ||
Internal actions | ||
- goals_accomplished | ||
""" | ||
Input | ||
The "content" key of an LLM response | ||
""" | ||
|
||
# Check for the existence of the "command" key in the log | ||
command_existence = bool(re.search(r'"command"\s*:', log)) | ||
|
||
if command_existence: | ||
# Convert the JSON-like string to a Python dictionary | ||
log_dict = json.loads(log) | ||
|
||
# Check if the "command" key exists and has a "name" key | ||
if "command" in log_dict and "name" in log_dict["command"]: | ||
command_name = log_dict["command"]["name"] | ||
|
||
# List of command names that signify an action | ||
action_command_names = [ | ||
"web_search", | ||
"write_to_file", | ||
"browse_website", | ||
"execute_python_file", | ||
"list_files", | ||
] | ||
|
||
# Check if the command name matches any in the list | ||
return command_name in action_command_names | ||
|
||
return False | ||
|
||
|
||
def is_openai_function(log): | ||
"""OpenAI API function calls are determined by the presence of the "function_call" key.""" | ||
return bool(re.search(r'"function_call"\s*:', log)) | ||
"""OpenAI API function calls are determined by the presence of the "function_call" key. | ||
Beebot | ||
World state actions | ||
- get_html_content | ||
- read_file | ||
- write_file | ||
- wolfram_alpha_query | ||
- write_python_code | ||
- execute_python_file | ||
- google_search | ||
- wikipedia | ||
Internal actions | ||
- get_more_tools | ||
- exit | ||
- rewind_actions | ||
PolyGPT | ||
World state actions | ||
- http.sendRequest | ||
- http.post | ||
- http.get | ||
- filesystem.writeFile | ||
- ethers.sendRpc | ||
Internal actions | ||
- LearnWrap | ||
- InvokeWrap | ||
Input | ||
The entire LLM response | ||
""" | ||
# Check for the existence of the "function_call" key in the log | ||
function_call_existence = bool(log.get("function_call", None)) | ||
|
||
if function_call_existence: | ||
# Check if the "function_call" key exists and has a "name" key | ||
if "name" in log["function_call"]: | ||
function_name = log["function_call"]["name"] | ||
|
||
# List of function names that signify an action | ||
action_function_names = [ | ||
"get_html_content", | ||
"read_file", | ||
"write_file", | ||
"wolfram_alpha_query", | ||
"write_python_code", | ||
"execute_python_file", | ||
"google_search", | ||
"wikipedia", | ||
"http.sendRequest", | ||
"http.post", | ||
"http.get", | ||
"filesystem.writeFile", | ||
"ethers.sendRpc", | ||
] | ||
|
||
# Check if the function name matches any in the list | ||
return function_name in action_function_names | ||
|
||
return False | ||
|
||
|
||
def is_action_miniagi(log): | ||
"""Mini-AGI function calls are determined by the presence of different patterns | ||
World state actions | ||
- execute_python | ||
- web_search | ||
Internal actions | ||
- done | ||
- talk_to_user | ||
""" | ||
# List of function names that signify an action | ||
action_function_names = ["execute_python", "web_search"] | ||
|
||
# Check for the <c>...</c> pattern and whether it matches any action function names | ||
c_pattern_match = False | ||
c_pattern_search = re.search(r"<c>(.*?)<\/c>", log) | ||
if c_pattern_search: | ||
c_pattern_match = c_pattern_search.group(1) in action_function_names | ||
|
||
# Check for the "ACTION:" pattern and whether it matches any action function names | ||
action_pattern_match = False | ||
action_pattern_search = re.search(r"ACTION:\s*(\w+)\s*(\(x\d+\))?", log) | ||
if action_pattern_search: | ||
action_pattern_match = action_pattern_search.group(1) in action_function_names | ||
|
||
return c_pattern_match or action_pattern_match | ||
|
||
|
||
def is_action_turbo(log): | ||
"""Turbos actions are defined by the presence of the "cmd" key. | ||
World state actions | ||
- search | ||
- www | ||
- py | ||
- aol | ||
- put | ||
- pyf | ||
Internal actions | ||
- end | ||
""" | ||
# List of function names that signify an action | ||
action_function_names = ["search", "www", "py", "aol", "put", "pyf"] | ||
|
||
# Check for the "cmd" key pattern and whether its "name" field matches any action function names | ||
cmd_pattern_match = False | ||
cmd_pattern_search = re.search(r'"cmd"\s*:\s*{\s*"name"\s*:\s*"(\w+)"', log) | ||
if cmd_pattern_search: | ||
cmd_pattern_match = cmd_pattern_search.group(1) in action_function_names | ||
|
||
return cmd_pattern_match | ||
|
||
|
||
def is_action_general(log): | ||
"""General actions are defined by the presence of specific keywords such as 'write', 'start', 'create', etc.""" | ||
return bool( | ||
re.search( | ||
r"\b(write|start|create|execute|post|modify|mutate|delete|put|search|find|get|browse|query|www|read|list)\b", | ||
log, | ||
) | ||
) | ||
|
||
|
||
# post, get, put, delete | ||
"""KEYWORDS FOUND SO FAR | ||
WRITE | ||
- write | ||
- start | ||
- create | ||
- execute | ||
- post | ||
MODIFY | ||
- modify | ||
- mutate | ||
- delete | ||
- put | ||
SEARCH | ||
- search | ||
- find | ||
- get | ||
- browse | ||
- query | ||
- www | ||
READ | ||
- read | ||
- list | ||
GENERAL, no specificity | ||
- command | ||
- call | ||
- function | ||
- action | ||
""" | ||
|
||
|
||
def is_action_agent(log, agent="", test="", response=""): | ||
"""Determines if a log contains an action based on patterns from different agents.""" | ||
is_action = False | ||
|
||
if log is None: | ||
print("Log is None", agent, test, response) | ||
return is_action | ||
|
||
log_content = log.get("content", "") | ||
|
||
if agent == "auto-gpt": | ||
is_action = is_action_auto_gpt(log_content) | ||
elif agent in ["beebot", "polygpt"]: | ||
is_action = is_openai_function(log) | ||
elif agent == "miniagi": | ||
is_action = is_action_miniagi(log_content) | ||
elif agent == "turbo": | ||
is_action = is_action_turbo(log_content) | ||
|
||
return is_action |
Oops, something went wrong.