Vadim212 commited on
Commit
e9ff287
1 Parent(s): ffc9504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -4,6 +4,7 @@ from transformers import AutoTokenizer, AutoModel
4
  import torch
5
  import pandas as pd
6
  import base64
 
7
 
8
  styleBase64 = 'PHN0eWxlPi8qIFRleHQgU3R5bGVzICovCmhyIHsgY29sb3I6ICMwMDAwMDB9CmJvZHksIHRhYmxlLCB0ciwgdGggLyogTm9ybWFsICovCnsKIGZvbnQtc2l6ZTogMTJwdDsKIGZvbnQtZmFtaWx5OiAnU2Vnb2UgVUknOwogZm9udC1zdHlsZTogbm9ybWFsOwogZm9udC13ZWlnaHQ6IG5vcm1hbDsKIGNvbG9yOiAjMDAwMDAwOwogdGV4dC1kZWNvcmF0aW9uOiBub25lOwp9CnNwYW4uZl9ibGF6b3IgLyogYmxhem9yICovCnsKIGZvbnQtc2l6ZTogMTBwdDsKIGZvbnQtZmFtaWx5OiAnQ291cmllciBOZXcnOwogY29sb3I6ICM4MDAwODA7Cn0Kc3Bhbi5mX2NibHVlIC8qIGNibHVlICovCnsKIGZvbnQtc2l6ZTogMTBwdDsKIGZvbnQtZmFtaWx5OiAnQ291cmllciBOZXcnOwogY29sb3I6ICMwMDAwZmY7Cn0Kc3Bhbi5mX2NjbGFzcyAvKiBjY2xhc3MgKi8KewogZm9udC1zaXplOiAxMHB0OwogZm9udC1mYW1pbHk6ICdDb3VyaWVyIE5ldyc7CiBjb2xvcjogIzAwODA4MDsKfQpzcGFuLmZfY2NvbW1lbnQgLyogY2NvbW1lbnQgKi8KewogZm9udC1zaXplOiAxMHB0OwogZm9udC1mYW1pbHk6ICdDb3VyaWVyIE5ldyc7CiBjb2xvcjogIzAwODAwMDsKfQpzcGFuLmZfY29kZSAvKiBjb2RlICovCnsKIGZvbnQtc2l6ZTogMTBwdDsKIGZvbnQtZmFtaWx5OiAnQ291cmllciBOZXcnOwp9CnNwYW4uZl9Db2RlRXhhbXBsZSAvKiBD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tc2hhZG93OiA1cHggNXB4IDVweCAjODg4Owp9CgphLmRyb3Bkb3duLXRvZ2dsZSAvKiBkcm9wZG93biB0b2dnbGUgY2FwdGlvbiAqLwp7CiAgY3Vyc29yOiBwb2ludGVyOwp9CmEuaW5saW5lLXRvZ2dsZSAvKiBpbmxpbmUgdG9nZ2xlIGNhcHRpb24gKi8KewogIGN1cnNvcjogcG9pbnRlcjsKfQppbWcuZHJvcGRvd24tdG9nZ2xlLWljb24gLyogdG9nZ2xlIGljb24gKi8KewogIGN1cnNvcjogcG9pbnRlcjsKfQo8L3N0eWxlPg=='
9
  style = base64.b64decode(styleBase64).decode("ascii")
@@ -37,7 +38,7 @@ embeddings_dataset.add_faiss_index(column="embeddings")
37
  def get_html(row):
38
  result = f"""<div style='font-size:16pt'>{row.title} <font style='font-size:10pt'>[{row.origin}]</font> </div>
39
  <div style='font-size:8pt'>{row.path}</div>
40
- {row.content}<br><a href='{row.url}' target='_blank'>Link</a>"""
41
  return result
42
 
43
  def find(question):
 
4
  import torch
5
  import pandas as pd
6
  import base64
7
+ import html
8
 
9
  styleBase64 = 'PHN0eWxlPi8qIFRleHQgU3R5bGVzICovCmhyIHsgY29sb3I6ICMwMDAwMDB9CmJvZHksIHRhYmxlLCB0ciwgdGggLyogTm9ybWFsICovCnsKIGZvbnQtc2l6ZTogMTJwdDsKIGZvbnQtZmFtaWx5OiAnU2Vnb2UgVUknOwogZm9udC1zdHlsZTogbm9ybWFsOwogZm9udC13ZWlnaHQ6IG5vcm1hbDsKIGNvbG9yOiAjMDAwMDAwOwogdGV4dC1kZWNvcmF0aW9uOiBub25lOwp9CnNwYW4uZl9ibGF6b3IgLyogYmxhem9yICovCnsKIGZvbnQtc2l6ZTogMTBwdDsKIGZvbnQtZmFtaWx5OiAnQ291cmllciBOZXcnOwogY29sb3I6ICM4MDAwODA7Cn0Kc3Bhbi5mX2NibHVlIC8qIGNibHVlICovCnsKIGZvbnQtc2l6ZTogMTBwdDsKIGZvbnQtZmFta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HMgKi8KewogIGRpc3BsYXk6IG5vbmU7CiAgcG9zaXRpb246IGFic29sdXRlOwogIHotaW5kZXg6IDEwMDA7CiAgYmFja2dyb3VuZC1jb2xvcjogI0ZGRkZGRjsKICBwYWRkaW5nOiAzcHg7CiAgYm9yZGVyOjFweCBzb2xpZCAjRkYwMDAwOwogIGJvcmRlci1yYWRpdXM6IDVweDsKICBib3gtc2hhZG93OiA1cHggNXB4IDVweCAjODg4Owp9CgojaG1saWdodGJveCAvKiBpbWFnZSBsaWdodGJveCAqLwp7CiAgYm9yZGVyOiBub25lOwogIHBhZGRpbmc6IDhweDsKICBiYWNrZ3JvdW5kOiAjRkZGOwogIGZvbnQtc2l6ZTogMTEwJTsKICBmb250LXdlaWdodDogYm9sZDsKICBjb2xvcjogIzc3NzsKICBib3gtc2hhZG93OiA1cHggNXB4IDVweCAjODg4Owp9CgphLmRyb3Bkb3duLXRvZ2dsZSAvKiBkcm9wZG93biB0b2dnbGUgY2FwdGlvbiAqLwp7CiAgY3Vyc29yOiBwb2ludGVyOwp9CmEuaW5saW5lLXRvZ2dsZSAvKiBpbmxpbmUgdG9nZ2xlIGNhcHRpb24gKi8KewogIGN1cnNvcjogcG9pbnRlcjsKfQppbWcuZHJvcGRvd24tdG9nZ2xlLWljb24gLyogdG9nZ2xlIGljb24gKi8KewogIGN1cnNvcjogcG9pbnRlcjsKfQo8L3N0eWxlPg=='
10
  style = base64.b64decode(styleBase64).decode("ascii")
 
38
  def get_html(row):
39
  result = f"""<div style='font-size:16pt'>{row.title} <font style='font-size:10pt'>[{row.origin}]</font> </div>
40
  <div style='font-size:8pt'>{row.path}</div>
41
+ {htnl.escape(row.content)}<br><a href='{row.url}' target='_blank'>Link</a>"""
42
  return result
43
 
44
  def find(question):