mirror of https://github.com/THUDM/ChatGLM-6B
Merge pull request #851 from hwaking/patch-1
当前MAX_BOXES与MAX_TURNS不生效导致单次对话不终止显存不断增加最后显存溢出问题pull/934/head^2
commit
467ce73f4c
|
@ -28,6 +28,8 @@ def predict(input, max_length, top_p, temperature, history=None):
|
||||||
|
|
||||||
with container:
|
with container:
|
||||||
if len(history) > 0:
|
if len(history) > 0:
|
||||||
|
if len(history)>MAX_BOXES:
|
||||||
|
history = history[-MAX_TURNS:]
|
||||||
for i, (query, response) in enumerate(history):
|
for i, (query, response) in enumerate(history):
|
||||||
message(query, avatar_style="big-smile", key=str(i) + "_user")
|
message(query, avatar_style="big-smile", key=str(i) + "_user")
|
||||||
message(response, avatar_style="bottts", key=str(i))
|
message(response, avatar_style="bottts", key=str(i))
|
||||||
|
@ -66,4 +68,4 @@ if 'state' not in st.session_state:
|
||||||
if st.button("发送", key="predict"):
|
if st.button("发送", key="predict"):
|
||||||
with st.spinner("AI正在思考,请稍等........"):
|
with st.spinner("AI正在思考,请稍等........"):
|
||||||
# text generation
|
# text generation
|
||||||
st.session_state["state"] = predict(prompt_text, max_length, top_p, temperature, st.session_state["state"])
|
st.session_state["state"] = predict(prompt_text, max_length, top_p, temperature, st.session_state["state"])
|
||||||
|
|
Loading…
Reference in New Issue