shlomihod commited on
Commit
09febb6
·
1 Parent(s): 53b4af3

switch complition to escaped markdowon

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -123,6 +123,27 @@ def get_processing_tokenizer():
123
  PROCESSING_TOKENIZER = get_processing_tokenizer()
124
 
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  def build_api_call_function(model, hf_token=None):
127
  if model.startswith("openai") or model.startswith("azure"):
128
  openai_lib = importlib.import_module("openai")
@@ -855,7 +876,7 @@ def main():
855
  st.error(e)
856
  st.stop()
857
 
858
- st.text(output)
859
 
860
 
861
  if __name__ == "__main__":
 
123
  PROCESSING_TOKENIZER = get_processing_tokenizer()
124
 
125
 
126
+ def escape_markdown(text):
127
+ escape_dict = {
128
+ "*": r"\*",
129
+ "_": r"\_",
130
+ "{": r"\{",
131
+ "}": r"\}",
132
+ "[": r"\[",
133
+ "]": r"\]",
134
+ "(": r"\(",
135
+ ")": r"\)",
136
+ "+": r"\+",
137
+ "-": r"\-",
138
+ ".": r"\.",
139
+ "!": r"\!",
140
+ "`": r"\`",
141
+ ">": r"\>",
142
+ "|": r"\|",
143
+ }
144
+ return "".join([escape_dict.get(c, c) for c in text])
145
+
146
+
147
  def build_api_call_function(model, hf_token=None):
148
  if model.startswith("openai") or model.startswith("azure"):
149
  openai_lib = importlib.import_module("openai")
 
876
  st.error(e)
877
  st.stop()
878
 
879
+ st.markdown(escape_markdown(output))
880
 
881
 
882
  if __name__ == "__main__":