fix: do not share session state across requests in m_serve examples - #1481
fix: do not share session state across requests in m_serve examples#1481markstur wants to merge 3 commits into
Conversation
Examples are holding the session across requests so that different client would share history. This doesn't significantly affect the examples, but it's a bad pattern if the example influences real implementations. Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> Assisted-by: IBM Bob Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
|
One thing outside this diff's scope, worth a quick follow-up: from mellea import start_session
...
session = start_session()
def serve(input: list[ChatMessage], ...):
...
result = session.instruct(...)
return resultThat's the exact shared-session pattern this PR is removing from the real examples. Anyone using this README snippet as a starting point for a new example would reintroduce the #1444 bug. Not a blocker for this PR, but worth updating the snippet (move Happy to approve once that's done. |
…xamples README.md The examples were fixed, but the README.me for the m serve examples still had the anti-pattern. It works either way, but we don't want people to learn or copy the anti-pattern. Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Done. Thanks for catching that. I feel like I looked at that, but just didn't see it. |
There was a problem hiding this comment.
Should probably update this since the model was updated to
hf.co/ibm-granite/granite-vision-4.1-4b-GGUF:Q4_K_M
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Examples are holding the session across requests so that different client would share history. This doesn't significantly affect the examples, but it's a bad pattern if the example influences real implementations.
Assisted-by: IBM Bob
Pull Request
Issue
Fixes #1444
Description
Testing
Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.