From e1d28ffc63e39af7583ecb56209c3f5f4afcd1e4 Mon Sep 17 00:00:00 2001 From: shbone <598924626@qq.com> Date: Wed, 6 Mar 2024 11:30:18 +0800 Subject: [PATCH] fix: fix project_dir bug and update readme --- README.md | 2 +- example/demo.py | 7 ++++++- src/FourthDimension/config/__init__.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec97deab..a563f9cb 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ conda activate FourthDimension 3. 安装FourthDimension 3.1 安装前置依赖 ``` -pip install -r dependency.txt -i https://pypi.tuna.tsinghua.edu.cn/simple +pip install -r dependencies.txt -i https://pypi.tuna.tsinghua.edu.cn/simple ```        3.2 安装FourthDimension ``` diff --git a/example/demo.py b/example/demo.py index d0d18397..d357f896 100644 --- a/example/demo.py +++ b/example/demo.py @@ -2,11 +2,16 @@ # -*- coding: utf-8 -*- # @Time : # @Author : wgh +import os import FourthDimension """ 文件说明: """ +# 当前脚本文件路径 +current_path = os.path.abspath(__file__) +# 获取当前脚本文件所在的目录 +current_dir = os.path.dirname(current_path) index_name = "default_docx" def upload_test(doc_path): @@ -14,7 +19,7 @@ def upload_test(doc_path): 导入文档到私域知识库测试 :return: """ - FourthDimension.upload(doc_path,index_name=index_name) + FourthDimension.upload(os.path.join(current_dir,doc_path),index_name=index_name) def query_test(question): diff --git a/src/FourthDimension/config/__init__.py b/src/FourthDimension/config/__init__.py index a30da59f..4ffcd5a5 100644 --- a/src/FourthDimension/config/__init__.py +++ b/src/FourthDimension/config/__init__.py @@ -21,7 +21,7 @@ resource_dir = f'{root_dir}/resources' project_dir = os.path.dirname(os.path.dirname(root_dir)) # 读取配置文件 -with open(f"{project_dir}/config.json", 'r', encoding='utf-8') as f: +with open(f"config.json", 'r', encoding='utf-8') as f: config_setting = dict(json.load(f)) # 读取问句模板 -- Gitee