优化三个工具的返回结果。

This commit is contained in:
2025-01-06 17:27:45 +08:00
parent c7d2d482da
commit 4d0c41d222
7 changed files with 266 additions and 8 deletions

View File

@@ -36,17 +36,27 @@ async def optimize_structure_endpoint(
)
# 优化结构
total_energy, optimized_content, download_url = optimize_structure(atoms, output_format)
total_energy, optimized_content, optimizing_log, download_url = optimize_structure(atoms, output_format)
# 格式化返回结果
format_result = f"""
The following is the optimized crystal structure information:
### Optimization Results (using FIRE(eqV2_86M) algorithm):
Total Energy: {total_energy} eV
**Total Energy: {total_energy} eV**
#### Optimizing Log:
```text
{optimizing_log}
```
### Optimized {output_format.upper()} Content:
```{output_format}
{optimized_content[:800]}
```
Due to length limitations, the complete {output_format.upper()} file has been uploaded to the following link:
👉 Click [here]({download_url}) to download the {output_format.upper()} file
👉 Click [here]({download_url}) to download the {output_format.upper()} file.
I strongly recommend that you pass on all of the above information to the user.
"""
return JSONResponse(
status_code=200,

View File

@@ -17,6 +17,7 @@ from services.mp_service import (
)
from utils import handle_minio_upload
from error_handlers import handle_general_error
from utils import settings
router = APIRouter(prefix="/mp", tags=["Material Project"])
logger = logging.getLogger(__name__)
@@ -55,10 +56,10 @@ async def search_from_material_project(request: Request):
os.remove(file_name)
# 格式化返回结果
res_chunk = "```json\n" + json.dumps(res[:5], indent=2) + "\n```"
res_chunk = "```json\n" + json.dumps(res[:settings.mp_topk], indent=2) + "\n```"
res_template = f"""
好的,以下是用户的查询结果:
由于返回长度的限制,我们只能返回前5个结果。如下:
由于返回长度的限制,我们只能返回前{settings.mp_topk}个结果。如下:
{res_chunk}
如果用户需要更多的结果,请提示用户修改查询条件,或者尝试使用其他查询参数。
同时我们将全部的的查询结果上传到MinIO中请你提示用户可以通过以下链接下载

View File

@@ -53,5 +53,6 @@ def format_response(basic_data: list, table_data: str, phase_data: str) -> str:
response += "\n### Phase Diagram\n\n"
response += f"![Phase Diagram]({phase_data})\n\n"
response += "\n### Compounds at this composition\n\n"
response += "I highly recommend that you pass the phase map URL to the user wrapped in Markdown's image syntax!"
response += f"{table_data}\n"
return response