You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My project initially ran in a graphical environment of=3.30.0, but later upgraded to 4.15 due to the need to add features. After the upgrade, the first step was to run the report error AttributeError: 'Textbox' object has no attribute 'style'. I tried to modify the code, removed the style function, resolved the error, and the webpage graph can be opened normally. But a new problem appeared again. After entering my question in the dialog box, the chatbot's answer was only replied to in the command box, not on the webpage Graph. At the same time, my command to clear the input box in gr.update was only executed once and no longer executed. But the program is running normally without any errors or termination.
Have you searched existing issues? 🔎
I have searched and found no existing issues
Reproduction
from transformers import AutoModel, AutoTokenizer
import gradio as gr
import mdtex2html
import os
tokenizer = AutoTokenizer.from_pretrained(".\model", trust_remote_code=True)
model = AutoModel.from_pretrained(".\model", trust_remote_code=True).quantize(4).half().cuda()
model = model.eval()
"""Override Chatbot.postprocess"""
def postprocess(self, y):
if y is None:
return []
for i, (message, response) in enumerate(y):
y[i] = (
None if message is None else mdtex2html.convert((message)),
None if response is None else mdtex2html.convert(response),
)
return y
gr.Chatbot.postprocess = postprocess
def parse_text(text):
"""copy from https://github.com/GaiZhenbiao/ChuanhuChatGPT/"""
lines = text.split("\n")
lines = [line for line in lines if line != ""]
count = 0
for i, line in enumerate(lines):
if "```" in line:
count += 1
items = line.split('') if count % 2 == 1: lines[i] = f'<pre><code class="language-{items[-1]}">' else: lines[i] = f'<br></code></pre>' else: if i > 0: if count % 2 == 1: line = line.replace("", "`")
line = line.replace("<", "<")
line = line.replace(">", ">")
line = line.replace(" ", " ")
line = line.replace("*", "*")
line = line.replace("_", "_")
line = line.replace("-", "-")
line = line.replace(".", ".")
line = line.replace("!", "!")
line = line.replace("(", "(")
line = line.replace(")", ")")
line = line.replace("$", "$")
lines[i] = " "+line
text = "".join(lines)
return text
def predict(input, chatbot, max_length, top_p, temperature, history):
chatbot.append((parse_text(input), ""))
for response, history in model.stream_chat(tokenizer, input, history, max_length=max_length, top_p=top_p,
temperature=temperature):
chatbot[-1] = (parse_text(input), parse_text(response))
If you still are experiencing issues, please provide a minimal repro with correctly formatted code that we can use to help you. As it stands, this issue includes too much code and incorrect formatting making it difficult to parse so I’ll close this issue for now, but can reopen if you please address these points.
Describe the bug
My project initially ran in a graphical environment of=3.30.0, but later upgraded to 4.15 due to the need to add features. After the upgrade, the first step was to run the report error AttributeError: 'Textbox' object has no attribute 'style'. I tried to modify the code, removed the style function, resolved the error, and the webpage graph can be opened normally. But a new problem appeared again. After entering my question in the dialog box, the chatbot's answer was only replied to in the command box, not on the webpage Graph. At the same time, my command to clear the input box in gr.update was only executed once and no longer executed. But the program is running normally without any errors or termination.
Have you searched existing issues? 🔎
Reproduction
from transformers import AutoModel, AutoTokenizer
import gradio as gr
import mdtex2html
import os
tokenizer = AutoTokenizer.from_pretrained(".\model", trust_remote_code=True)
model = AutoModel.from_pretrained(".\model", trust_remote_code=True).quantize(4).half().cuda()
model = model.eval()
"""Override Chatbot.postprocess"""
def postprocess(self, y):
if y is None:
return []
for i, (message, response) in enumerate(y):
y[i] = (
None if message is None else mdtex2html.convert((message)),
None if response is None else mdtex2html.convert(response),
)
return y
gr.Chatbot.postprocess = postprocess
def parse_text(text):
"""copy from https://github.com/GaiZhenbiao/ChuanhuChatGPT/"""
lines = text.split("\n")
lines = [line for line in lines if line != ""]
count = 0
for i, line in enumerate(lines):
if "```" in line:
count += 1
items = line.split('
') if count % 2 == 1: lines[i] = f'<pre><code class="language-{items[-1]}">' else: lines[i] = f'<br></code></pre>' else: if i > 0: if count % 2 == 1: line = line.replace("
", "`")line = line.replace("<", "<")
line = line.replace(">", ">")
line = line.replace(" ", " ")
line = line.replace("*", "*")
line = line.replace("_", "_")
line = line.replace("-", "-")
line = line.replace(".", ".")
line = line.replace("!", "!")
line = line.replace("(", "(")
line = line.replace(")", ")")
line = line.replace("$", "$")
lines[i] = "
"+line
text = "".join(lines)
return text
def predict(input, chatbot, max_length, top_p, temperature, history):
chatbot.append((parse_text(input), ""))
for response, history in model.stream_chat(tokenizer, input, history, max_length=max_length, top_p=top_p,
temperature=temperature):
chatbot[-1] = (parse_text(input), parse_text(response))
def reset_user_input():
return gr.update(value='')
def reset_state():
return [], []
with gr.Blocks() as demo:
gr.HTML("""
ChatGLM
""")demo.queue().launch(share=False, inbrowser=True)
Screenshot
Logs
No response
System Info
Severity
Blocking usage of gradio
The text was updated successfully, but these errors were encountered: