-
Notifications
You must be signed in to change notification settings - Fork 8
Implement the minimal version of task manager #197
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
Open
MalithaPrabhashana
wants to merge
1
commit into
main
Choose a base branch
from
minimal-version-task-manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,102 @@ | ||
import from byllm.llm { Model } | ||
|
||
glob llm = Model(model_name="gpt-4o", verbose=False); | ||
|
||
node Task { | ||
has task:str = ""; | ||
has date:str = ""; | ||
has time:str = ""; | ||
} | ||
|
||
node TaskHandling { | ||
def add_task(task: Task) -> str { | ||
self ++> task; | ||
return "Task added successfully"; | ||
} | ||
def check_scheduled_tasks -> list[Task] { | ||
self ++> Task( | ||
task="Check scheduled tasks", | ||
date="2025-10-10", | ||
time="10:00:00" | ||
); # Add a sample task for demonstration | ||
return [self --> (`?Task)]; | ||
} | ||
def extract_task_info(utterance: str) -> str by llm( | ||
method="ReAct", | ||
tools=([self.add_task]) | ||
); | ||
def summarize_tasks() -> str by llm( | ||
method="ReAct", | ||
tools=([self.check_scheduled_tasks]) | ||
); | ||
def route_and_run(utterance: str) -> str by llm( | ||
method="ReAct", | ||
tools=([self.extract_task_info, self.summarize_tasks]) | ||
); | ||
can execute with task_manager entry { | ||
print("[TaskHandling Node Activated]"); | ||
response = self.route_and_run(visitor.utterance); | ||
print("→", response); | ||
} | ||
} | ||
|
||
node EmailHandling { | ||
def write_email_content(utterance: str) -> str by llm(); | ||
def route_and_run(utterance: str) -> str by llm( | ||
method="ReAct", | ||
tools=([self.write_email_content]) | ||
); | ||
can execute with task_manager entry { | ||
print("[EmailHandling Node Activated]"); | ||
response = self.route_and_run(visitor.utterance); | ||
print("→", response); | ||
} | ||
} | ||
|
||
node GeneralChat { | ||
def chat(utterance: str) -> str by llm(); | ||
can execute with task_manager entry { | ||
print("[GeneralChat Node Activated]"); | ||
response = self.chat(visitor.utterance); | ||
print("→", response); | ||
} | ||
} | ||
|
||
enum RoutingNodes{ | ||
TASK_HANDLING = "TaskHandling", | ||
EMAIL_HANDLING = "EmailHandling", | ||
GENERAL_CHAT = "GeneralChat" | ||
} | ||
|
||
walker task_manager { | ||
has utterance: str = ""; | ||
|
||
def route_to_node(utterance: str) -> RoutingNodes by llm(); | ||
can execute with `root entry { | ||
routed_node_name = self.route_to_node(self.utterance); | ||
|
||
if routed_node_name == RoutingNodes.TASK_HANDLING { | ||
routed_node = here ++> TaskHandling(); | ||
} elif routed_node_name == RoutingNodes.EMAIL_HANDLING { | ||
routed_node = here ++> EmailHandling(); | ||
} elif routed_node_name == RoutingNodes.GENERAL_CHAT { | ||
routed_node = here ++> GeneralChat(); | ||
} | ||
visit routed_node; | ||
} | ||
} | ||
|
||
with entry { | ||
inputs: list = [ | ||
"Write an email to my friend which has the email [email protected] to inform that I need to arrange a meeting regarding the project.", | ||
"Can you add a task to buy the Robotics items before tomorrow 12 noon", | ||
"Summarize all my tasks", | ||
"What was the popular programming language in 2020?" | ||
]; | ||
|
||
for input in inputs { | ||
print("User Input: " + input); | ||
task_manager(utterance=input) spawn root; | ||
print("====================================================================\n"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont think we need the = "TaskHandling" etc. Can just use comma's (The LLM will see the enum name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I tested it without using these strings inside the Enum. But then it couldn't identify the exact routing node. @marsninja