Spaces:
Sleeping
Squash merge main into newgradio
Browse filescommit 13edad804483914294548a9ffcf0fd028d39cc03
Author: Keldos <i@keldos.me>
Date: Fri Jun 2 12:05:54 2023 +0800
Revert 为适配 gradio 3.30.0 适配做出的更改
This reverts commit de613b48355a2594dabca66b2192723b67bf92b4.
This reverts commit 6c96d6f0ed17c74df567b4fd8ac4c1a60ea24c7a.
commit daf68a9ee8769e0373d00688139759355c874edc
Author: Tuchuanhuhuhu <gzblog@hdu.edu.cn>
Date: Fri Jun 2 10:51:39 2023 +0800
修复索引逻辑 #789
commit fe0c8bd35daacbca78e5f31f7aaadf76a69c7dfb
Author: Tuchuanhuhuhu <gzblog@hdu.edu.cn>
Date: Fri Jun 2 01:23:57 2023 +0800
改进生成 embedding 时的稳定性
commit dc61f72798839dca3ec16f20aa2810ef6df618a4
Author: Tuchuanhuhuhu <gzblog@hdu.edu.cn>
Date: Fri Jun 2 01:23:36 2023 +0800
改进 config 写入环境变量的方式
commit 4f8449f8cf0f43bde25298c7f85ee418a019e045
Author: Tuchuanhuhuhu <gzblog@hdu.edu.cn>
Date: Thu Jun 1 14:01:54 2023 +0800
更新 gradioclient 版本
commit bfac445e799c317b0f5e738ab394032a18de62eb
Author: Tuchuanhuhuhu <gzblog@hdu.edu.cn>
Date: Thu Jun 1 10:40:10 2023 +0800
增加 blocked path
- modules/config.py +3 -4
- modules/index_func.py +3 -4
- requirements.txt +1 -1
@@ -102,10 +102,9 @@ if api_host is not None:
|
|
102 |
shared.state.set_api_host(api_host)
|
103 |
|
104 |
default_chuanhu_assistant_model = config.get("default_chuanhu_assistant_model", "gpt-3.5-turbo")
|
105 |
-
|
106 |
-
|
107 |
-
os.environ[
|
108 |
-
os.environ["SERPAPI_API_KEY"] = config.get("SERPAPI_API_KEY", "")
|
109 |
|
110 |
@contextmanager
|
111 |
def retrieve_openai_api(api_key = None):
|
|
|
102 |
shared.state.set_api_host(api_host)
|
103 |
|
104 |
default_chuanhu_assistant_model = config.get("default_chuanhu_assistant_model", "gpt-3.5-turbo")
|
105 |
+
for x in ["GOOGLE_CSE_ID", "GOOGLE_API_KEY", "WOLFRAM_ALPHA_APPID", "SERPAPI_API_KEY"]:
|
106 |
+
if config.get(x, None) is not None:
|
107 |
+
os.environ[x] = config[x]
|
|
|
108 |
|
109 |
@contextmanager
|
110 |
def retrieve_openai_api(api_key = None):
|
@@ -51,7 +51,7 @@ def get_documents(file_src):
|
|
51 |
pdfReader = PyPDF2.PdfReader(pdfFileObj)
|
52 |
for page in tqdm(pdfReader.pages):
|
53 |
pdftext += page.extract_text()
|
54 |
-
texts = Document(page_content=pdftext, metadata={"source": filepath})
|
55 |
elif file_type == ".docx":
|
56 |
logging.debug("Loading Word...")
|
57 |
from langchain.document_loaders import UnstructuredWordDocumentLoader
|
@@ -71,8 +71,7 @@ def get_documents(file_src):
|
|
71 |
logging.debug("Loading Excel...")
|
72 |
text_list = excel_to_string(filepath)
|
73 |
for elem in text_list:
|
74 |
-
|
75 |
-
continue
|
76 |
else:
|
77 |
logging.debug("Loading text file...")
|
78 |
from langchain.document_loaders import TextLoader
|
@@ -83,7 +82,7 @@ def get_documents(file_src):
|
|
83 |
logging.error(f"Error loading file: {filename}")
|
84 |
traceback.print_exc()
|
85 |
|
86 |
-
texts = text_splitter.split_documents(
|
87 |
documents.extend(texts)
|
88 |
logging.debug("Documents loaded.")
|
89 |
return documents
|
|
|
51 |
pdfReader = PyPDF2.PdfReader(pdfFileObj)
|
52 |
for page in tqdm(pdfReader.pages):
|
53 |
pdftext += page.extract_text()
|
54 |
+
texts = [Document(page_content=pdftext, metadata={"source": filepath})]
|
55 |
elif file_type == ".docx":
|
56 |
logging.debug("Loading Word...")
|
57 |
from langchain.document_loaders import UnstructuredWordDocumentLoader
|
|
|
71 |
logging.debug("Loading Excel...")
|
72 |
text_list = excel_to_string(filepath)
|
73 |
for elem in text_list:
|
74 |
+
texts.append(Document(page_content=elem, metadata={"source": filepath}))
|
|
|
75 |
else:
|
76 |
logging.debug("Loading text file...")
|
77 |
from langchain.document_loaders import TextLoader
|
|
|
82 |
logging.error(f"Error loading file: {filename}")
|
83 |
traceback.print_exc()
|
84 |
|
85 |
+
texts = text_splitter.split_documents(texts)
|
86 |
documents.extend(texts)
|
87 |
logging.debug("Documents loaded.")
|
88 |
return documents
|
@@ -1,5 +1,5 @@
|
|
1 |
gradio==3.33.0
|
2 |
-
gradio_client==0.
|
3 |
mdtex2html
|
4 |
pypinyin
|
5 |
tiktoken
|
|
|
1 |
gradio==3.33.0
|
2 |
+
gradio_client==0.2.4
|
3 |
mdtex2html
|
4 |
pypinyin
|
5 |
tiktoken
|