Skip to content

Commit c19c3df

Browse files
fix(gradio): escape <cite /> blocks in gradio chat
1 parent a7018a4 commit c19c3df

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

supermat/gradio/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ def chat(self, message: str, _history):
190190
# history_langchain_format = self.convert_history_to_messages(history)
191191
# history_langchain_format.append(HumanMessage(content=message))
192192
gpt_response = self.chain.invoke(message)
193-
return gpt_response if isinstance(gpt_response, str) else gpt_response.content
193+
gpt_response = gpt_response if isinstance(gpt_response, str) else gpt_response.content
194+
gpt_response = re.sub(r"<cite\b[^>]*?/>", r"``\g<0>``", gpt_response)
195+
return gpt_response
194196

195197
except Exception as e:
196198
raise gr.Error(f"Error: {str(e)}\n{traceback.format_exc()}")

0 commit comments

Comments
 (0)