mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 20:27:58 +00:00
upgraded
This commit is contained in:
parent
ddcf439ffd
commit
c68b687e7c
@ -123,6 +123,8 @@ async def lollms_generate(request: LollmsGenerateRequest):
|
|||||||
headers = { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive',}
|
headers = { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive',}
|
||||||
reception_manager=RECEPTION_MANAGER()
|
reception_manager=RECEPTION_MANAGER()
|
||||||
prompt = request.prompt
|
prompt = request.prompt
|
||||||
|
if elf_server.config.debug:
|
||||||
|
ASCIIColors.yellow(prompt)
|
||||||
n_predict = request.n_predict if request.n_predict>0 else 1024
|
n_predict = request.n_predict if request.n_predict>0 else 1024
|
||||||
stream = request.stream
|
stream = request.stream
|
||||||
prompt_tokens = len(elf_server.binding.tokenize(prompt))
|
prompt_tokens = len(elf_server.binding.tokenize(prompt))
|
||||||
@ -189,15 +191,12 @@ async def lollms_generate(request: LollmsGenerateRequest):
|
|||||||
# Yield each chunk of data
|
# Yield each chunk of data
|
||||||
if chunk is None:
|
if chunk is None:
|
||||||
return True
|
return True
|
||||||
|
reception_manager.reception_buffer += chunk
|
||||||
rx = reception_manager.new_chunk(chunk)
|
antiprompt = elf_server.personality.detect_antiprompt(reception_manager.reception_buffer)
|
||||||
if rx.status!=ROLE_CHANGE_DECISION.MOVE_ON:
|
if antiprompt:
|
||||||
if rx.status==ROLE_CHANGE_DECISION.PROGRESSING:
|
ASCIIColors.warning(f"\n{antiprompt} detected. Stopping generation")
|
||||||
return True
|
reception_manager.reception_buffer = elf_server.remove_text_from_string(reception_manager.reception_buffer,antiprompt)
|
||||||
elif rx.status==ROLE_CHANGE_DECISION.ROLE_CHANGED:
|
return False
|
||||||
return False
|
|
||||||
else:
|
|
||||||
chunk = chunk + rx.value
|
|
||||||
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user