-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Added ability to specify 'role' field for select speaker messages for Group Chats (addresses #1861) #2167
Closed
Closed
Added ability to specify 'role' field for select speaker messages for Group Chats (addresses #1861) #2167
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d5b0159
Added role_for_select_speaker_messages for setting role name
marklysze 7e7c38a
Merge branch 'microsoft:main' into 1861-role
marklysze bb5d52c
Added Mistral AI link and notebook (thanks ekzhu), tips for non-OpenA…
marklysze 748ec45
Tweak of wording on notebook
marklysze cc512d1
Added example of role setting in tips page and adding info to Group C…
marklysze f96d35b
Merge remote-tracking branch 'upstream/main' into 1861-role
marklysze 5320521
Merge branch 'main' into 1861-role
marklysze 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -716,7 +716,7 @@ def _print_received_message(self, message: Union[Dict, str], sender: Agent): | |||||
if "function_call" in message and message["function_call"]: | ||||||
function_call = dict(message["function_call"]) | ||||||
func_print = ( | ||||||
f"***** Suggested function call: {function_call.get('name', '(No function name found)')} *****" | ||||||
f"***** Suggested function Call: {function_call.get('name', '(No function name found)')} *****" | ||||||
) | ||||||
iostream.print(colored(func_print, "green"), flush=True) | ||||||
iostream.print( | ||||||
|
@@ -728,7 +728,7 @@ def _print_received_message(self, message: Union[Dict, str], sender: Agent): | |||||
iostream.print(colored("*" * len(func_print), "green"), flush=True) | ||||||
if "tool_calls" in message and message["tool_calls"]: | ||||||
for tool_call in message["tool_calls"]: | ||||||
id = tool_call.get("id", "No tool call id found") | ||||||
id = tool_call.get("id", "(No id found)") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
function_call = dict(tool_call.get("function", {})) | ||||||
func_print = f"***** Suggested tool call ({id}): {function_call.get('name', '(No function name found)')} *****" | ||||||
iostream.print(colored(func_print, "green"), flush=True) | ||||||
|
@@ -1311,12 +1311,6 @@ def _generate_oai_reply_from_client(self, llm_client, messages, cache) -> Union[ | |||||
) | ||||||
for tool_call in extracted_response.get("tool_calls") or []: | ||||||
tool_call["function"]["name"] = self._normalize_name(tool_call["function"]["name"]) | ||||||
# Remove id and type if they are not present. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were for Mistral AI compatibility. Are these not needed now? |
||||||
# This is to make the tool call object compatible with Mistral API. | ||||||
if tool_call.get("id") is None: | ||||||
tool_call.pop("id") | ||||||
if tool_call.get("type") is None: | ||||||
tool_call.pop("type") | ||||||
return extracted_response | ||||||
|
||||||
async def a_generate_oai_reply( | ||||||
|
@@ -1546,6 +1540,7 @@ def generate_tool_calls_reply( | |||||
message = messages[-1] | ||||||
tool_returns = [] | ||||||
for tool_call in message.get("tool_calls", []): | ||||||
id = tool_call["id"] | ||||||
function_call = tool_call.get("function", {}) | ||||||
func = self._function_map.get(function_call.get("name", None), None) | ||||||
if inspect.iscoroutinefunction(func): | ||||||
|
@@ -1563,24 +1558,13 @@ def generate_tool_calls_reply( | |||||
loop.close() | ||||||
else: | ||||||
_, func_return = self.execute_function(function_call) | ||||||
content = func_return.get("content", "") | ||||||
if content is None: | ||||||
content = "" | ||||||
tool_call_id = tool_call.get("id", None) | ||||||
if tool_call_id is not None: | ||||||
tool_call_response = { | ||||||
"tool_call_id": tool_call_id, | ||||||
tool_returns.append( | ||||||
{ | ||||||
"tool_call_id": id, | ||||||
"role": "tool", | ||||||
"content": content, | ||||||
"content": func_return.get("content", ""), | ||||||
} | ||||||
else: | ||||||
# Do not include tool_call_id if it is not present. | ||||||
# This is to make the tool call object compatible with Mistral API. | ||||||
tool_call_response = { | ||||||
"role": "tool", | ||||||
"content": content, | ||||||
} | ||||||
tool_returns.append(tool_call_response) | ||||||
) | ||||||
if tool_returns: | ||||||
return True, { | ||||||
"role": "tool", | ||||||
|
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
Oops, something went wrong.
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.
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.