-
Notifications
You must be signed in to change notification settings - Fork 15.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
Adding a Character Chat Agent #4411
Adding a Character Chat Agent #4411
Conversation
-------------------- | ||
Given the entire TOOLS RESPONSE, | ||
- If the USER'S ORIGINAL INPUT isn't answered using ONLY the information obtained by TOOL, try the same tool with a different input or another tool. | ||
- Otherwise, how would Assistant respond using information obtained from TOOL, Assistant must NOT mention the tool or tool names - the user has no context of any TOOL RESPONSES! |
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.
It looks like this is a run-on sentence; could this be re-written? Perhaps something like:
Otherwise, to respond using information obtained from TOOL, Assistant must NOT mention the tool or tool names - the user has no context of any TOOL RESPONSES!
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.
Good point. I think I had copied and pasted some of the conversational chat prompt in and it didn't make sense move on .
@@ -0,0 +1 @@ | |||
"""An agent designed to hold a conversation with a character in addition to using tools.""" |
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.
Would it be more accurate to rephrase this as "An agent designed to hold a conversation as a given character in addition to using tools."
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.
Definitely correct!
@@ -0,0 +1,133 @@ | |||
"""An agent designed to hold a conversation with a character in addition to using tools.""" |
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.
Would it be more accurate to rephrase this as "An agent designed to hold a conversation as a given character in addition to using tools."
|
||
|
||
class CharacterChatAgent(Agent): | ||
"""An agent designed to hold a conversation in addition to using tools.""" |
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.
Would it be more accurate to rephrase this as "An agent designed to hold a conversation as a given character in addition to using tools."
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.
Same comment as above. Incorporating.
|
||
When responding to the TOOL, please output a response in one of two formats: | ||
|
||
**Option 1:** |
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.
**Option #1:**
instead of **Option 1:**
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.
Adding this into the prompt.
|
||
MORE INSTRUCTIONS | ||
-------------------- | ||
Given the entire TOOLS RESPONSE, |
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.
TOOLS
-> TOOL
RESPONSE FORMAT INSTRUCTIONS | ||
---------------------------- | ||
|
||
When responding to the TOOL, please output a response in one of two formats: |
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.
When responding to the TOOL
-> When responding to TOOL
Thanks @treppers for the PR! This kind of agent looks like it could make writing dialogue agents much more streamlined.
|
Trying to put together a notebook that will do a good compare and contrast. That should be inbound. I do think the Conversational Chat agent needs updating and so when I get the notebook up you can see the issues I found. Definitely open to expanding the prompt to apply to conversation partner. Would just need to test it to make sure it doesn't think the TOOL voice is a conversation partner. Updating this branch with a notebook to execute this agent along with the suggested tweaks. Also found a bug in the prompt that was causing the Option #1 response to include additional conversational responses in addition to the markdown. |
…h Option 1 included non-markdown. added a notebook to execute this.
format_instructions = character_message.format( | ||
format_instructions=_output_parser.get_format_instructions() | ||
) | ||
final_prompt = format_instructions.format( |
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.
final_prompt = format_instructions.format( | |
system_prompt = format_instructions.format( |
how about naming it to system_prompt
as it is no more final
?
return thoughts | ||
|
||
@classmethod | ||
def from_llm_and_tools( |
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.
I saw this piece of code in several places, ever considered inheriting ConversationalChatAgent
?
Thanks for the update @treppers! Curious to see what you find in the compare-and-contrast. |
Hey @mbchang ! This PR no longer lines up with the current directory structure of the library (would need to be in /libs/langchain/langchain instead of /langchain). Would you be interested in updating to the new format, or would it be better to close this and someone can work on a new PR off the current state of the library (using this as a reference implementation)? |
I'll close it for now, and let me know if you'd like to reopen! |
Character Chat Agent
Fork of the conversational chat agent, but added in the concept of personality and fixed some issues I was getting with the output_parser. You can provide a {character_summary} that will give your bot that personality.
I was noticing some occasional weird responses with the conversation_chat agent so rewrote the entire prompt which seemed to have fixed some of them. Also noticed some errors with output_parser (but will submit that as a separate PR).
Changes with the prompt:
Output_parser changes:
Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested:
@hwchase17