Imporve /open command: detetive target before open.

This commit is contained in:
Liu Zhicong
2023-10-03 18:52:10 -07:00
parent a92b3f15dc
commit 4f43c4abed
5 changed files with 25 additions and 7 deletions
+1
View File
@@ -1,4 +1,5 @@
# OpenDAN Quick Start # OpenDAN Quick Start
OpenDAN (Open and Do Anything Now with AI) is revolutionizing the AI landscape with its Personal AI Operating System. Designed for seamless integration of diverse AI modules, it ensures unmatched interoperability. OpenDAN empowers users to craft powerful AI agents—from butlers and assistants to personal tutors and digital companions—all while retaining control. These agents can team up to tackle complex challenges, integrate with existing services, and command smart(IoT) devices. OpenDAN (Open and Do Anything Now with AI) is revolutionizing the AI landscape with its Personal AI Operating System. Designed for seamless integration of diverse AI modules, it ensures unmatched interoperability. OpenDAN empowers users to craft powerful AI agents—from butlers and assistants to personal tutors and digital companions—all while retaining control. These agents can team up to tackle complex challenges, integrate with existing services, and command smart(IoT) devices.
With OpenDAN, we're putting AI in your hands, making life simpler and smarter. With OpenDAN, we're putting AI in your hands, making life simpler and smarter.
-5
View File
@@ -39,11 +39,6 @@ class CalenderEnvironment(Environment):
self.add_ai_function(SimpleAIFunction("get_time", self.add_ai_function(SimpleAIFunction("get_time",
"get current time", "get current time",
self._get_now)) self._get_now))
#self.add_ai_function(SimpleAIFunction("serach_events",
# "search events in calender",
# self._search_events))
get_param = { get_param = {
"start_time": "start time (UTC) of event", "start_time": "start time (UTC) of event",
"end_time": "end time (UTC) of event" "end_time": "end time (UTC) of event"
@@ -48,6 +48,12 @@ class AgentManager:
pass pass
async def is_exist(self,agent_id:str) -> bool:
the_aget = await self.get(agent_id)
if the_aget:
return True
return False
async def get(self,agent_id:str) -> AIAgent: async def get(self,agent_id:str) -> AIAgent:
the_agent = self.loaded_agent_instance.get(agent_id) the_agent = self.loaded_agent_instance.get(agent_id)
if the_agent: if the_agent:
@@ -57,7 +57,13 @@ class WorkflowManager:
if await self._load_workflow_agents(sub_workflow) is False: if await self._load_workflow_agents(sub_workflow) is False:
return False return False
return True return True
async def is_exist(self,workflow_id:str) -> bool:
the_workflow = await self.get_workflow(workflow_id)
if the_workflow:
return True
return False
async def get_workflow(self,workflow_id:str) -> Workflow: async def get_workflow(self,workflow_id:str) -> Workflow:
the_workflow : Workflow = self.loaded_workflow.get(workflow_id) the_workflow : Workflow = self.loaded_workflow.get(workflow_id)
if the_workflow: if the_workflow:
+11 -1
View File
@@ -233,7 +233,7 @@ class AIOS_Shell:
match tunnel_type: match tunnel_type:
case "telegram": case "telegram":
tunnel_config["type"] = "TelegramTunnel" tunnel_config["type"] = "TelegramTunnel"
input_table["token"] = UserConfigItem("telegram bot token") input_table["token"] = UserConfigItem("telegram bot token\n You can get it from https://t.me/BotFather ,read https://core.telegram.org/bots#how-do-i-create-a-bot for more details")
input_table["allow"] = UserConfigItem("allow group (default is member,you can choose contact or guest)") input_table["allow"] = UserConfigItem("allow group (default is member,you can choose contact or guest)")
case "email": case "email":
tunnel_config["type"] = "EmailTunnel" tunnel_config["type"] = "EmailTunnel"
@@ -491,6 +491,16 @@ class AIOS_Shell:
else: else:
topic = "default" topic = "default"
target_exist = False
if await AgentManager.get_instance().is_exist(target_id):
target_exist = True
if await WorkflowManager.get_instance().is_exist(target_id):
target_exist = True
if target_exist is False:
show_text = FormattedText([("class:error", f"Target {target_id} not exist!")])
return show_text
self.current_target = target_id self.current_target = target_id
self.current_topic = topic self.current_topic = topic
show_text = FormattedText([("class:title", f"current session switch to {topic}@{target_id}")]) show_text = FormattedText([("class:title", f"current session switch to {topic}@{target_id}")])