add qwen-agent

This commit is contained in:
朱潮 2025-10-09 11:00:41 +08:00
parent d123a67da1
commit 8011e5d2cb
7 changed files with 49 additions and 16 deletions

View File

@ -7,7 +7,6 @@ WORKDIR /app
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV AGENT_POOL_SIZE=1
# 安装系统依赖
RUN sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources && \
@ -39,7 +38,7 @@ EXPOSE 8001
# 健康检查
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8001/ || exit 1
CMD curl -f http://localhost:8001/api/health"|| exit 1
# 启动命令
CMD ["python", "fastapi_app.py"]

View File

@ -58,7 +58,7 @@
### 阶段0数据集探索
**目标**:识别可用数据集,确定查询目标
**执行步骤**
1. **目录扫描**:查看data目录下的所有数据集文件夹
1. **目录扫描**:查看[当前数据目录]下的所有数据集文件夹
2. **数据集选择**:根据用户需求选择合适的数据集文件夹
### 阶段1智能索引分析

View File

@ -18,7 +18,7 @@ services:
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/"]
test: ["CMD", "curl", "-f", "http://localhost:8001/api/health"]
interval: 30s
timeout: 10s
retries: 3

View File

@ -0,0 +1 @@
Test document content

View File

@ -0,0 +1 @@
Subdirectory document content

Binary file not shown.

View File

@ -27,11 +27,19 @@ class ZipProjectHandler:
"""获取URL的哈希值用于缓存"""
return hashlib.md5(url.encode('utf-8')).hexdigest()[:16]
def _is_valid_url(self, url: str) -> bool:
"""验证URL是否有效"""
def _is_valid_url_or_path(self, path: str) -> bool:
"""验证URL或本地路径是否有效"""
# 首先尝试作为URL验证
try:
result = urlparse(url)
return all([result.scheme, result.netloc])
result = urlparse(path)
if all([result.scheme, result.netloc]):
return True
except Exception:
pass
# 然后尝试作为本地路径验证
try:
return Path(path).exists()
except Exception:
return False
@ -51,6 +59,16 @@ class ZipProjectHandler:
print(f"下载文件失败: {e}")
return False
def _copy_local_file(self, local_path: str, target_path: str) -> bool:
"""复制本地文件到目标路径"""
try:
import shutil
shutil.copy2(local_path, target_path)
return True
except Exception as e:
print(f"复制本地文件失败: {e}")
return False
def _extract_zip(self, zip_path: str, extract_to: str) -> bool:
"""解压ZIP文件到指定目录"""
try:
@ -63,16 +81,16 @@ class ZipProjectHandler:
def get_project_from_zip(self, zip_url: str) -> Optional[str]:
"""
从ZIP URL获取项目数据
从ZIP URL或本地路径获取项目数据
Args:
zip_url: ZIP文件的URL
zip_url: ZIP文件的URL或本地相对路径
Returns:
Optional[str]: 成功时返回项目目录路径失败时返回None
"""
if not self._is_valid_url(zip_url):
print(f"无效的URL: {zip_url}")
if not self._is_valid_url_or_path(zip_url):
print(f"无效的URL或路径: {zip_url}")
return None
# 检查缓存
@ -83,14 +101,28 @@ class ZipProjectHandler:
print(f"使用缓存的项目目录: {cached_project_dir}")
return str(cached_project_dir)
# 下载ZIP文件
# 下载或复制ZIP文件
zip_filename = f"{url_hash}.zip"
zip_path = self.cache_dir / zip_filename
if not zip_path.exists():
print(f"下载ZIP文件: {zip_url}")
if not self._download_file(zip_url, str(zip_path)):
return None
# 判断是URL还是本地路径
try:
result = urlparse(zip_url)
is_url = all([result.scheme, result.netloc])
except Exception:
is_url = False
if is_url:
print(f"下载ZIP文件: {zip_url}")
if not self._download_file(zip_url, str(zip_path)):
return None
else:
print(f"复制本地ZIP文件: {zip_url}")
# 解析相对路径
local_path = Path(zip_url).resolve()
if not self._copy_local_file(str(local_path), str(zip_path)):
return None
else:
print(f"使用缓存的ZIP文件: {zip_path}")