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

Add permission dev #396

Merged
merged 52 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
443e02d
execution permission migration added
Fluder-Paradyne Jun 12, 2023
3169f96
execution permission migration added
Fluder-Paradyne Jun 12, 2023
433d08f
backend poc done
Fluder-Paradyne Jun 13, 2023
ce652cd
agent execution feed id added to permission
Fluder-Paradyne Jun 13, 2023
02afb79
skip feed if it is empty
Fluder-Paradyne Jun 13, 2023
92e61d6
removed agent_execution_feed_id which was added by mistake
Fluder-Paradyne Jun 13, 2023
0c97566
temp save
Fluder-Paradyne Jun 14, 2023
082690e
poc before test
Fluder-Paradyne Jun 14, 2023
1235537
bug fix
Fluder-Paradyne Jun 14, 2023
ebf9c49
new migration
Fluder-Paradyne Jun 14, 2023
1edaab8
add permission_required property to base_tool.py
Fluder-Paradyne Jun 14, 2023
4fc073a
permissions
Parth2506 Jun 14, 2023
b3ca9ff
Merge branch 'add_permission' of github.com:TransformerOptimus/SuperA…
jedan2506 Jun 14, 2023
a4d7cfe
permissions
jedan2506 Jun 14, 2023
b07b361
updates
jedan2506 Jun 14, 2023
522b6e2
updates
jedan2506 Jun 14, 2023
ec4d9e7
added curd for agent_execution_permission
Fluder-Paradyne Jun 15, 2023
1b1010e
added route
Fluder-Paradyne Jun 15, 2023
d7dd927
added update agent_execution_permission api and
Fluder-Paradyne Jun 15, 2023
ba78a69
added user_response to permission update endpoint
Fluder-Paradyne Jun 15, 2023
8da8ca5
permissions updates
jedan2506 Jun 15, 2023
7070732
Merge branch 'add_permission' of github.com:TransformerOptimus/SuperA…
jedan2506 Jun 15, 2023
9f3ed15
revert changes
Fluder-Paradyne Jun 15, 2023
e1b6761
permissions updates
jedan2506 Jun 15, 2023
9b20561
Merge remote-tracking branch 'origin/add_permission' into add_permission
Fluder-Paradyne Jun 15, 2023
f3b6a9d
skip permissions which have already been accepted or denied
Fluder-Paradyne Jun 16, 2023
4805dfc
space added
Fluder-Paradyne Jun 16, 2023
e61efff
merge with master
Fluder-Paradyne Jun 16, 2023
0c066d1
migrations fix
Fluder-Paradyne Jun 16, 2023
4b13f3b
permissions updates
jedan2506 Jun 16, 2023
05053a6
Merge branch 'add_permission' of github.com:TransformerOptimus/SuperA…
jedan2506 Jun 16, 2023
4c43e32
feedback working text
Fluder-Paradyne Jun 16, 2023
733c618
remove !
Fluder-Paradyne Jun 16, 2023
4ebf510
typo
Fluder-Paradyne Jun 16, 2023
44e0ee0
permissions updates
jedan2506 Jun 16, 2023
1b824ef
Merge branch 'add_permission' of github.com:TransformerOptimus/SuperA…
jedan2506 Jun 16, 2023
e612c48
pr changes
Fluder-Paradyne Jun 16, 2023
4a090d3
Merge remote-tracking branch 'origin/add_permission' into add_permission
Fluder-Paradyne Jun 16, 2023
c5929b3
small refactor
Fluder-Paradyne Jun 16, 2023
2f04a76
added .get instead of directly accessing dict
Fluder-Paradyne Jun 16, 2023
c26c165
response to user_feedback
Fluder-Paradyne Jun 16, 2023
ac9cead
added test test_handle_wait_for_permission.py
Fluder-Paradyne Jun 17, 2023
9703d24
added index on agent_execution_id in agent_execution_permissions table
Fluder-Paradyne Jun 17, 2023
ed814c0
check_permission test added
Fluder-Paradyne Jun 17, 2023
711031c
docs for agent_execution_permission.py
Fluder-Paradyne Jun 17, 2023
ed75e1b
dev merge
Fluder-Paradyne Jun 17, 2023
2e595f1
merge with dev
Fluder-Paradyne Jun 19, 2023
21285ae
added comment
Fluder-Paradyne Jun 19, 2023
3c33d90
added comment and UI dropdown text change
Fluder-Paradyne Jun 19, 2023
62e1adc
tests run outside docker
Fluder-Paradyne Jun 19, 2023
fba2b95
comment update
Fluder-Paradyne Jun 19, 2023
b4dc41b
Merge branch 'dev' into add_permission
Jun 19, 2023
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
Prev Previous commit
Next Next commit
add permission_required property to base_tool.py
  • Loading branch information
Fluder-Paradyne committed Jun 14, 2023
commit 1edaab8526f610cb7706e26b72162989bcc320c0
7 changes: 6 additions & 1 deletion superagi/agent/super_agi.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,15 @@ def execute(self, template_step: AgentTemplateStep):
role="assistant")
session.add(agent_execution_feed)
session.commit()

action = self.output_parser.parse(assistant_reply)
tools = {t.name: t for t in self.tools}

excluded_tools = [FINISH, '', None]

# get the last agent execution permission for this agent execution
if self.agent_config["permission_type"].upper() == "RESTRICTED":
if self.agent_config["permission_type"].upper() == "RESTRICTED" and action.name not in excluded_tools and \
tools[action.name].permission_required:
new_agent_execution_permission = AgentExecutionPermission(
agent_execution_id=self.agent_config["agent_execution_id"],
agent_id=self.agent_config["agent_id"],
Expand Down
21 changes: 1 addition & 20 deletions superagi/controllers/agent_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,8 @@ def update_agent_execution_permission(agent_execution_permission_id: int,
if status is None:
raise HTTPException(status_code=400, detail="Invalid Request status is required")
agent_execution_permission.status = status
# if status:
# agent_execution_permission.status = True
# # result = SuperAgi(ai_name=None, ai_role=None,
# # llm=None, tools=,
# # memory=memory,
# # agent_config=parsed_config).handle_tool_response(agent_execution_permission.assistant_reply)['result']
# else:
# agent_execution_permission.status = False
# result = f"user rejected to access to run {agent_execution_permission.tool_name}"
# agent_execution_permission.response = response
db.session.commit()
# db_agent_execution = db.session.query(AgentExecution). \
# get(agent_execution_permission.agent_execution_id)
# db_agent_execution.status = "RUNNING"
# agent_execution_feed = AgentExecutionFeed(agent_execution_id=agent_execution_permission.agent_execution_id,
# agent_id=agent_execution_permission.agent_id,
# feed=result,
# role="system"
# )
# db.session.add(agent_execution_feed)
# db.session.commit()

execute_agent.delay(agent_execution_permission.agent_execution_id, datetime.now())

return {"success": True}
8 changes: 5 additions & 3 deletions superagi/jobs/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ def execute_next_action(self, agent_execution_id):
agent_execution.status = "RUNNING"
agent_execution_permission = session.query(AgentExecutionPermission).filter(
AgentExecutionPermission.id == agent_execution.permission_id).first()

result = spawned_agent.handle_tool_response(agent_execution_permission.assistant_reply)
if agent_execution_permission.status:
result = spawned_agent.handle_tool_response(agent_execution_permission.assistant_reply).get("result")
else:
result = f"user denied the permission to run the tool {agent_execution_permission.tool_name}"

agent_execution_feed = AgentExecutionFeed(agent_execution_id=agent_execution_permission.agent_execution_id,
agent_id=agent_execution_permission.agent_id,
feed=result.get("result"),
feed=result,
role="system"
)
session.add(agent_execution_feed)
Expand Down
5 changes: 5 additions & 0 deletions superagi/tools/base_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def _execute(self, *args: Any, **kwargs: Any):
def max_token_limit(self):
return get_config("MAX_TOOL_TOKEN_LIMIT", 600)

# permission required to run tool in Restricted mode
@property
def permission_required(self):
return True

def _parse_input(
self,
tool_input: Union[str, Dict],
Expand Down
4 changes: 4 additions & 0 deletions superagi/tools/thinking/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class ThinkingTool(BaseTool):
args_schema: Type[ThinkingSchema] = ThinkingSchema
goals: List[str] = []

@property
def permission_required(self):
return False

class Config:
arbitrary_types_allowed = True

Expand Down