Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,36 +20,6 @@ key = "AIzaSyDJ4vIKuIBIPNHATLxnoHlagXWbsAz-vRs"
|
|
20 |
|
21 |
# Cấu hình API key cho Google GenAI
|
22 |
genai.configure(api_key=key)
|
23 |
-
|
24 |
-
### loop cho tất cả các file tài liệu và cộng lại thành final_all_split (nhét vào 1 database)
|
25 |
-
|
26 |
-
folder_path = 'syllabus_nct_word_format/'
|
27 |
-
docx_files = list_docx_files(folder_path)
|
28 |
-
|
29 |
-
all_splits = [] # Khởi tạo danh sách lưu kết quả
|
30 |
-
for i, file_path in enumerate(tqdm(docx_files, desc="Đang xử lý", unit="file")):
|
31 |
-
output_json_path = f"output_{i}.json"
|
32 |
-
splits = get_splits(file_path, output_json_path)
|
33 |
-
all_splits += splits
|
34 |
-
|
35 |
-
# output_json_path = "output_{i}.json"
|
36 |
-
# splits = get_splits(docx_files, output_json_path)
|
37 |
-
# all_splits += splits
|
38 |
-
|
39 |
-
FAQ_path = 'syllabus_nct_word_format/FAQ.json'
|
40 |
-
FAQ_splits = get_json_splits_only(FAQ_path)
|
41 |
-
all_splits += FAQ_splits
|
42 |
-
|
43 |
-
# web_path = 'https'
|
44 |
-
# web_splits = await get_urls_splits(url='https://nct.neu.edu.vn/')
|
45 |
-
# all_splits += web_splits
|
46 |
-
|
47 |
-
# Lưu vào vectorstore với nhúng từ GenAI (Cần chỉ định model)
|
48 |
-
embedding = GoogleGenerativeAIEmbeddings(model="models/text-embedding-004")
|
49 |
-
vectorstore = FAISS.from_documents(documents=all_splits, embedding=embedding)
|
50 |
-
|
51 |
-
###
|
52 |
-
|
53 |
institutions = ['Tất cả'] + ['Trường Công Nghệ']
|
54 |
categories = ['Tất cả'] + ['Đề án', 'Chương trình đào tạo']
|
55 |
|
|
|
20 |
|
21 |
# Cấu hình API key cho Google GenAI
|
22 |
genai.configure(api_key=key)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
institutions = ['Tất cả'] + ['Trường Công Nghệ']
|
24 |
categories = ['Tất cả'] + ['Đề án', 'Chương trình đào tạo']
|
25 |
|