Update app.py
Browse files
app.py
CHANGED
|
@@ -11,12 +11,8 @@ import chardet
|
|
| 11 |
import pandas as pd
|
| 12 |
import plotly.graph_objs as go
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
except NameError:
|
| 17 |
-
SCRIPT_DIR = os.getcwd()
|
| 18 |
-
|
| 19 |
-
CSV_PATH = os.path.join(SCRIPT_DIR, "evaluations.csv")
|
| 20 |
|
| 21 |
def detect_encoding(file_path):
|
| 22 |
with open(file_path, 'rb') as file:
|
|
@@ -38,7 +34,7 @@ def setup(file_path):
|
|
| 38 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
|
| 39 |
all_splits = text_splitter.split_documents(document_data)
|
| 40 |
|
| 41 |
-
persist_directory = 'db'
|
| 42 |
model_name = "sentence-transformers/all-MiniLM-L6-v2"
|
| 43 |
model_kwargs = {'device': 'cpu'}
|
| 44 |
embedding = HuggingFaceEmbeddings(model_name=model_name, model_kwargs=model_kwargs)
|
|
@@ -197,7 +193,7 @@ def create_demo():
|
|
| 197 |
return demo
|
| 198 |
|
| 199 |
if __name__ == "__main__":
|
| 200 |
-
print(f"CSV file is located at: {
|
| 201 |
demo = create_demo()
|
| 202 |
demo.launch(share=True)
|
| 203 |
else:
|
|
|
|
| 11 |
import pandas as pd
|
| 12 |
import plotly.graph_objs as go
|
| 13 |
|
| 14 |
+
# 使用 Hugging Face Space 的持久存儲路徑
|
| 15 |
+
CSV_PATH = os.path.expanduser("~/evaluations.csv")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def detect_encoding(file_path):
|
| 18 |
with open(file_path, 'rb') as file:
|
|
|
|
| 34 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
|
| 35 |
all_splits = text_splitter.split_documents(document_data)
|
| 36 |
|
| 37 |
+
persist_directory = '~/db'
|
| 38 |
model_name = "sentence-transformers/all-MiniLM-L6-v2"
|
| 39 |
model_kwargs = {'device': 'cpu'}
|
| 40 |
embedding = HuggingFaceEmbeddings(model_name=model_name, model_kwargs=model_kwargs)
|
|
|
|
| 193 |
return demo
|
| 194 |
|
| 195 |
if __name__ == "__main__":
|
| 196 |
+
print(f"CSV file is located at: {CSV_PATH}")
|
| 197 |
demo = create_demo()
|
| 198 |
demo.launch(share=True)
|
| 199 |
else:
|