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
[RPG GAME]FunctionAgent Version #236
Open
Southpika
wants to merge
18
commits into
PaddlePaddle:develop
Choose a base branch
from
Southpika:app
base: develop
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
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
Conversation
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #236 +/- ##
========================================
Coverage 69.61% 69.61%
========================================
Files 62 62
Lines 3100 3100
========================================
Hits 2158 2158
Misses 942 942 ☔ View full report in Codecov by Sentry. |
Southpika
commented
Dec 28, 2023
Comment on lines
+66
to
+92
async def _chat(history): | ||
prompt = history[-1][0] | ||
response = await self.run(prompt) | ||
self.memory.msg_manager.messages[-1] = AIMessage( | ||
eval(response.chat_history[2].content)["return_story"] | ||
) | ||
raw_messages.extend(response.chat_history) | ||
if len(response.chat_history) >= 3: | ||
output_result = eval(response.chat_history[2].content)["return_story"] | ||
else: | ||
output_result = response.text | ||
if response.steps and response.steps[-1].output_files: | ||
# If there is a file output in the last round, then we need to show it. | ||
output_file = response.steps[-1].output_files[-1] | ||
file_content = await output_file.read_contents() | ||
if get_file_type(output_file.filename) == "image": | ||
# If it is a image, we can display it in the same chat page. | ||
base64_encoded = base64.b64encode(file_content).decode("utf-8") | ||
output_result = eval(response.chat_history[2].content)[ | ||
"return_story" | ||
] + IMAGE_HTML.format(BASE64_ENCODED=base64_encoded) | ||
history[-1][1] = output_result | ||
return ( | ||
history, | ||
_messages_to_dicts(raw_messages), | ||
_messages_to_dicts(self.memory.get_messages()), | ||
) |
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.
因具体_chat函数部分有修改,因此不能直接继承launch_gradio_demo方法
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
1.添加通过FunctionAgent实现的版本
待tool_choice以及文生图工具ready
TODO: