MetaGPT
MetaGPT copied to clipboard
feat(core): Add stream data return and reception
- add file: utils/steam_pipe.py
- add demo: samples/flask_web_api.py
- Other core code modifications, Add and use the StreamPipe class at night
- Add flask library to requirements
Features
- xx
- yy
Feature Docs
Influence Not affecting other functions
Result
Download this MD file here
Other
Codecov Report
Attention: Patch coverage is 0%
with 17 lines
in your changes are missing coverage. Please review.
Project coverage is 81.18%. Comparing base (
6434503
) to head (f646715
). Report is 245 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
metagpt/utils/stream_pipe.py | 0.00% | 17 Missing :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## main #1118 +/- ##
==========================================
- Coverage 81.52% 81.18% -0.34%
==========================================
Files 248 249 +1
Lines 13895 13912 +17
==========================================
- Hits 11328 11295 -33
- Misses 2567 2617 +50
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Awesome! Let’s start Code Review now!
@2495165664 . This is a good example, but the introduction of stream_pipe
has intruded upon the original implementation. We can optimize it. With the help of metagpt.logs.set_llm_stream_logfunc
and contextvars.ContextVar
, we can achieve the same functionality without modifying any code under the metagpt
directory.
Update the metagpt/utils/stream_pipe.py
:
...
from contextvars import ContextVar
from metagpt.logs import set_llm_stream_logfunc
stream_pipe_var: ContextVar[StreamPipe] = ContextVar("stream_pipe")
def stream_pipe_log(content):
stream_pipe = stream_pipe_var.get(None)
if stream_pipe :
stream_pipe.set_message(content)
set_llm_stream_logfunc(stream_pipe_log)
def write_tutorial(message):
async def main(idea, stream_pipe):
stream_pipe_var.set(stream_pipe)
role = TutorialAssistant()
await role.run(idea)
...
Hello, there are still some CRs that need to be modified. After modification, they can be merged.
lgtm
@2495165664 there is a conflict
<<<<<<< main
"web-api": ["flask==3.0.2"],
=======
"android_assistant": ["pyshine==0.0.9", "opencv-python==4.6.0.66"],
>>>>>>> main
you should keep web-api
and android_assistant
both.