diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-04-17 10:35:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 10:35:08 +0200 |
commit | 0f04dacdbdba067152ebd4c1f7c23df8c9422295 (patch) | |
tree | 4e80161355a866d6e533c74dcca84494b6c2a5bf /g4f/locals/provider.py | |
parent | add cohere provider. (diff) | |
parent | Update event loop on windows only for old curl_cffi (diff) | |
download | gpt4free-0f04dacdbdba067152ebd4c1f7c23df8c9422295.tar gpt4free-0f04dacdbdba067152ebd4c1f7c23df8c9422295.tar.gz gpt4free-0f04dacdbdba067152ebd4c1f7c23df8c9422295.tar.bz2 gpt4free-0f04dacdbdba067152ebd4c1f7c23df8c9422295.tar.lz gpt4free-0f04dacdbdba067152ebd4c1f7c23df8c9422295.tar.xz gpt4free-0f04dacdbdba067152ebd4c1f7c23df8c9422295.tar.zst gpt4free-0f04dacdbdba067152ebd4c1f7c23df8c9422295.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/locals/provider.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/g4f/locals/provider.py b/g4f/locals/provider.py index 45041539..d9d73455 100644 --- a/g4f/locals/provider.py +++ b/g4f/locals/provider.py @@ -66,9 +66,12 @@ class LocalProvider: if message["role"] != "system" ) + "\nASSISTANT: " + def should_not_stop(token_id: int, token: str): + return "USER" not in token + with model.chat_session(system_message, prompt_template): if stream: - for token in model.generate(conversation, streaming=True): + for token in model.generate(conversation, streaming=True, callback=should_not_stop): yield token else: - yield model.generate(conversation)
\ No newline at end of file + yield model.generate(conversation, callback=should_not_stop)
\ No newline at end of file |