-
Notifications
You must be signed in to change notification settings - Fork 790
Improved planning via introduction of sub steps in MagUI plans #267
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
raghav-2002-os
wants to merge
5
commits into
microsoft:main
Choose a base branch
from
raghav-2002-os:msri_enhanced_planning
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 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0019c6a
MSRI Enhanced Planning Added
raghav-2002-os 3d94ed7
poe checks performed
raghav-2002-os 977cba1
Merge branch 'microsoft:main' into msri_enhanced_planning
raghav-2002-os d8b80a4
Merge branch 'microsoft:main' into msri_enhanced_planning
raghav-2002-os a2f3f0e
Updated Orchestrator Config
raghav-2002-os 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 | ||||
---|---|---|---|---|---|---|
|
@@ -50,6 +50,7 @@ | |||||
get_orchestrator_system_message_planning, | ||||||
get_orchestrator_system_message_planning_autonomous, | ||||||
get_orchestrator_plan_prompt_json, | ||||||
get_orchestrator_enhanced_plan_prompt_json, | ||||||
get_orchestrator_plan_replan_json, | ||||||
get_orchestrator_progress_ledger_prompt, | ||||||
ORCHESTRATOR_SYSTEM_MESSAGE_EXECUTION, | ||||||
|
@@ -58,6 +59,7 @@ | |||||
INSTRUCTION_AGENT_FORMAT, | ||||||
validate_ledger_json, | ||||||
validate_plan_json, | ||||||
validate_enhanced_plan_json, | ||||||
) | ||||||
from ._utils import is_accepted_str, extract_json_from_string | ||||||
from loguru import logger as trace_logger | ||||||
|
@@ -182,6 +184,8 @@ def __init__( | |||||
# Setup internal variables | ||||||
self._setup_internals() | ||||||
|
||||||
self.enhanced_plan = True | ||||||
|
||||||
def _setup_internals(self) -> None: | ||||||
""" | ||||||
Setup internal variables used in orchestrator | ||||||
|
@@ -252,6 +256,18 @@ def _get_task_ledger_plan_prompt(self, team: str) -> str: | |||||
team=team, additional_instructions=additional_instructions | ||||||
) | ||||||
|
||||||
def _get_task_ledger_plan_prompt_enhanced(self, team: str, user_query: str) -> str: | ||||||
additional_instructions = "" | ||||||
if self._config.allowed_websites is not None: | ||||||
additional_instructions = ( | ||||||
"Only use the following websites if possible: " | ||||||
+ ", ".join(self._config.allowed_websites) | ||||||
) | ||||||
|
||||||
return get_orchestrator_enhanced_plan_prompt_json().format( | ||||||
team=team, additional_instructions=additional_instructions,user_query=user_query | ||||||
) | ||||||
|
||||||
def _get_task_ledger_replan_plan_prompt( | ||||||
self, task: str, team: str, plan: str | ||||||
) -> str: | ||||||
|
@@ -315,6 +331,9 @@ def _validate_ledger_json(self, json_response: Dict[str, Any]) -> bool: | |||||
|
||||||
def _validate_plan_json(self, json_response: Dict[str, Any]) -> bool: | ||||||
return validate_plan_json(json_response, self._config.sentinel_tasks) | ||||||
|
||||||
def _validate_enhanced_plan_json(self, json_response: Dict[str, Any]) -> bool: | ||||||
return validate_enhanced_plan_json(json_response) | ||||||
|
||||||
async def validate_group_state( | ||||||
self, messages: List[BaseChatMessage] | None | ||||||
|
@@ -394,6 +413,25 @@ async def _request_next_speaker( | |||||
cancellation_token=cancellation_token, | ||||||
) | ||||||
|
||||||
async def change_format(self,response): | ||||||
husseinmozannar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
husseinmozannar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
output = { | ||||||
"terms": response.get('terms', ''), | ||||||
'response': response.get('response', ''), | ||||||
'task': response.get('task', {}), | ||||||
'plan_summary': response.get('plan_summary', ''), | ||||||
'needs_plan': response.get('needs_plan', False), | ||||||
'steps': [] | ||||||
} | ||||||
for step in response.get('steps', {}).values(): | ||||||
agent_name = step.get('agent_name', '') | ||||||
for substep in step.get('substeps', {}).values(): | ||||||
output['steps'].append({ | ||||||
'title': substep['title'], | ||||||
'details': substep['details'], | ||||||
'agent_name': agent_name | ||||||
}) | ||||||
return output | ||||||
|
||||||
async def _get_json_response( | ||||||
self, | ||||||
messages: List[LLMMessage], | ||||||
|
@@ -757,15 +795,28 @@ async def _orchestrate_step_planning( | |||||
await self._handle_relevant_plan_from_memory(context=context) | ||||||
|
||||||
# create a first plan | ||||||
context.append( | ||||||
if self.enhanced_plan: | ||||||
user_query = context[1].content | ||||||
context.append( | ||||||
UserMessage( | ||||||
content=self._get_task_ledger_plan_prompt(self._team_description), | ||||||
content=self._get_task_ledger_plan_prompt_enhanced(self._team_description,user_query), | ||||||
source=self._name, | ||||||
)) | ||||||
plan_response = await self._get_json_response( | ||||||
context, self._validate_enhanced_plan_json, cancellation_token | ||||||
) | ||||||
) | ||||||
plan_response = await self._get_json_response( | ||||||
context, self._validate_plan_json, cancellation_token | ||||||
) | ||||||
plan_response = await self.change_format(plan_response) | ||||||
else: | ||||||
context.append( | ||||||
UserMessage( | ||||||
content=self._get_task_ledger_plan_prompt(self._team_description), | ||||||
source=self._name, | ||||||
) | ||||||
) | ||||||
plan_response = await self._get_json_response( | ||||||
context, self._validate_plan_json, cancellation_token | ||||||
) | ||||||
|
||||||
if self._state.is_paused: | ||||||
# let user speak next if paused | ||||||
await self._request_next_speaker( | ||||||
|
@@ -817,17 +868,30 @@ async def _orchestrate_step_planning( | |||||
) | ||||||
if self._config.retrieve_relevant_plans == "hint": | ||||||
await self._handle_relevant_plan_from_memory(context=context) | ||||||
context.append( | ||||||
|
||||||
if self.enhanced_plan: | ||||||
user_query = context[1].content | ||||||
context.append( | ||||||
UserMessage( | ||||||
content=self._get_task_ledger_plan_prompt( | ||||||
self._team_description | ||||||
), | ||||||
content=self._get_task_ledger_plan_prompt_enhanced(self._team_description,user_query), | ||||||
|
content=self._get_task_ledger_plan_prompt_enhanced(self._team_description,user_query), | |
content=self._get_task_ledger_plan_prompt_enhanced(self._team_description, user_query), |
Copilot uses AI. Check for mistakes.
Positive FeedbackNegative Feedback
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.