update chatglm_llm.py
This commit is contained in:
parent
a1033698dd
commit
3b4b660d3c
|
|
@ -68,7 +68,21 @@ class ChatGLM(LLM):
|
||||||
|
|
||||||
def _call(self,
|
def _call(self,
|
||||||
prompt: str,
|
prompt: str,
|
||||||
stop: Optional[List[str]] = None) -> str:
|
stop: Optional[List[str]] = None,
|
||||||
|
stream=True) -> str:
|
||||||
|
if stream:
|
||||||
|
self.history = self.history + [[None, ""]]
|
||||||
|
response, _ = self.model.stream_chat(
|
||||||
|
self.tokenizer,
|
||||||
|
prompt,
|
||||||
|
history=self.history[-self.history_len:] if self.history_len > 0 else [],
|
||||||
|
max_length=self.max_token,
|
||||||
|
temperature=self.temperature,
|
||||||
|
)
|
||||||
|
torch_gc()
|
||||||
|
self.history[-1][-1] = response
|
||||||
|
yield response
|
||||||
|
else:
|
||||||
response, _ = self.model.chat(
|
response, _ = self.model.chat(
|
||||||
self.tokenizer,
|
self.tokenizer,
|
||||||
prompt,
|
prompt,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue