更新算法工具

main
fanpt
parent a1cc33d89e
commit 385c41486f

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="fanpt@192.168.0.102:22 password">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="fanpt@192.168.0.102:22 password (2)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="fanpt@192.168.0.102:22 password (3)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="fanpt@192.168.0.102:22 password (4)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="fanpt@192.168.0.102:22 password (5)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="fanpt@192.168.0.102:22 password (6)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="fanpt@192.168.0.102:22 password (7)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

@ -0,0 +1,28 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="14">
<item index="0" class="java.lang.String" itemvalue="protobuf" />
<item index="1" class="java.lang.String" itemvalue="transformers" />
<item index="2" class="java.lang.String" itemvalue="tensorboard" />
<item index="3" class="java.lang.String" itemvalue="icetk" />
<item index="4" class="java.lang.String" itemvalue="cpm_kernels" />
<item index="5" class="java.lang.String" itemvalue="peft" />
<item index="6" class="java.lang.String" itemvalue="accelerate" />
<item index="7" class="java.lang.String" itemvalue="torch" />
<item index="8" class="java.lang.String" itemvalue="datasets" />
<item index="9" class="java.lang.String" itemvalue="bitsandbytes" />
<item index="10" class="java.lang.String" itemvalue="ConcurrentLogHandler" />
<item index="11" class="java.lang.String" itemvalue="uwsgi" />
<item index="12" class="java.lang.String" itemvalue="ultralytics" />
<item index="13" class="java.lang.String" itemvalue="tool_helpers" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="virtual_patient_qa" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="virtual_patient_qa" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/interro_robot_tool.iml" filepath="$PROJECT_DIR$/.idea/interro_robot_tool.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,3 @@
from paddlespeech.cli.tts.infer import TTSExecutor
tts = TTSExecutor()
tts(text="今天天气十分不错。", output="output.wav")

@ -1,3 +1,44 @@
# interro_robot_tool
# Interro_robot_tool
审讯机器人算法工具
审讯小机器人
## 安装说明
这个项目需要在 Conda 环境中运行。以下是安装的步骤:
### 1. 安装 Conda
如果您尚未安装 Conda请根据您的操作系统安装 Miniconda 或 Anaconda。您可以从以下链接下载并安装 Conda
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
- [Anaconda](https://www.anaconda.com/products/distribution)
### 2. 创建虚拟环境
打开终端(或命令提示符),并输入以下命令以创建名为`qa_env`的 Conda 虚拟环境,确保使用 Python 3.10
```bash
conda create --name qa_env python=3.10
```
### 3. 激活虚拟环境
一旦环境创建完成,您需要激活虚拟环境。在 Windows 上,您可以使用以下命令
```bash
conda activate qa_env
```
### 4. 安装对应包
```bash
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
```
### 5. 进入项目目录,运行接口程序
```
cd virtual_patient_qa
python fast_api.py
```

@ -1,163 +0,0 @@
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
idea/
.idea/
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

@ -1,44 +0,0 @@
# Similarity_calculation_tool
相似度问题判断工具
## 安装说明
这个项目需要在 Conda 环境中运行。以下是安装的步骤:
### 1. 安装 Conda
如果您尚未安装 Conda请根据您的操作系统安装 Miniconda 或 Anaconda。您可以从以下链接下载并安装 Conda
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
- [Anaconda](https://www.anaconda.com/products/distribution)
### 2. 创建虚拟环境
打开终端(或命令提示符),并输入以下命令以创建名为`qa_env`的 Conda 虚拟环境,确保使用 Python 3.10
```bash
conda create --name qa_env python=3.10
```
### 3. 激活虚拟环境
一旦环境创建完成,您需要激活虚拟环境。在 Windows 上,您可以使用以下命令
```bash
conda activate qa_env
```
### 4. 安装对应包
```bash
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
```
### 5. 进入项目目录,运行接口程序
```
cd virtual_patient_qa
python fast_api.py
```

@ -1,2 +0,0 @@
cfee1e07-744b-45d4-985a-db344ce1cd98
f19754c8-6d82-4446-b019-81521fe78763

@ -0,0 +1,2 @@
a0f9848b-2d65-4b37-85ca-6712061f01c0
38de6667-4f5d-4f0a-8165-992ab76c1424

@ -29,7 +29,7 @@ logger = logging.getLogger(__name__)
class QuestionRequest(BaseModel):
question: str
scoreThreshold: float
class QuestionResponse(BaseModel):
@ -39,7 +39,7 @@ class QuestionResponse(BaseModel):
class QuestionItem(BaseModel):
questionCode: str
questionId: str
questionList: list[str]
@ -83,26 +83,6 @@ def update_kb(kb_name, qa_service, path, max_knowledge_bases):
f"Please wait while the database is being updated···")
def fetch_and_write_data(api_url, path):
"""从API获取数据并写入文件"""
try:
response = requests.get(api_url)
response_data = response.json()
if response.status_code == 200 and response_data["code"] == 200:
question_items = response_data["data"]
with open(path, "w", encoding="utf-8") as file:
json.dump(question_items, file, ensure_ascii=False, indent=2)
return True
else:
logger.error(f"Failed to fetch data from API. Status code: {response.status_code}, Response data: {response_data}")
return False
except Exception as e:
logger.error(f"Error fetching data from API: {e}")
return False
@app.post("/updateDatabase")
async def save_to_json(question_items: list[QuestionItem], background_tasks: BackgroundTasks):
@ -141,12 +121,11 @@ def match_question(request: QuestionRequest):
newest = recent_knowledge_bases[-1]
top_k = 3
score_threshold = 0.1
device = None
qa_service = QAService(newest, device)
result = match_query(qa_service, query, top_k, score_threshold)
result = match_query(qa_service, query, top_k, request.scoreThreshold)
response = QuestionResponse(code=200, msg="success", data=result)
stop_time = time.time()
@ -162,11 +141,6 @@ def match_question(request: QuestionRequest):
recent_knowledge_bases = deque(load_knowledge_bases(), maxlen=max_knowledge_bases)
if fetch_and_write_data(api_url, path):
kb_name = str(uuid.uuid4())
device = None
qa_service = QAService(kb_name, device)
update_kb(kb_name, qa_service, path, max_knowledge_bases)
if __name__ == "__main__":
import uvicorn

@ -51,7 +51,7 @@ def load_testing_data(file_path):
with open(file_path, encoding='utf-8') as f:
data = json.load(f)
for item in data:
question_code = item['questionCode']
question_code = item['questionId']
question_list.extend(item['questionList'])
id_list.extend([create_question_id(question_code, j, q) for j, q in enumerate(item['questionList'])])
Loading…
Cancel
Save