相关产品:
面向深度的查询问答和调研分析需求场景,多步骤推理规划研究路径,生成有洞察、可溯源、图文并茂的长文报告-大模型服务平台百炼(Model Studio)-阿里云帮助中心
深度搜索应用生成结果报告文件 (md、html、pdf) 的获取。
请求语法
POST /deep-search-agent/file/expose HTTP/1.1
请求参数
参数名
类型
是否必须
默认值
说明
input
object
是
输入字段
input.request_id
str
否
请求ID(业务自定义)
input.writing_result_path
str
是
None
文件路径
input.writing_result_type
str
是
"html_url"
获取类型,可选[html, html_url, md, md_url, pdf_url]
parameters
object
是
配置参数字段,该接口下留空 {}
示例
请求示例
{
"input": {
"request_id": "b4d140f0-07b4-90cb-b13d-b29c9ac37fda",
"writing_result_path": "msearch/agents/files/upload/5c81a***7da1151",
"writing_result_type": "html_url"
},
"parameters": {}
}
返回示例
{
"code": "200",
"message": "Success",
"output": {
"request_id": "b4d140f0-07b4-90cb-b13d-b29c9ac37fda",
"result": [
{
"text": "https://***.aliyuncs.com/***/agents/files/upload/5c81a***7da1151.html?***",
"type": "html_url"
}
]
}
}
调用示例
Python示例:
# coding=utf-8
import os
import sys
import uuid
import json
import requests
from http import HTTPStatus
file_expose_url = "https://dashscope.aliyuncs.com/api/v2/apps/deep-search-agent/file/expose"
headers = {
'Authorization': f'Bearer {os.getenv("DASHSCOPE_API_KEY", "")}', # 配置 API KEY
'Content-Type': 'application/json'
}
def get_file_export_info(file_path: str) -> dict:
api_key = os.getenv("DASHSCOPE_API_KEY")
if not api_key:
print("please set DASHSCOPE_API_KEY environment variable")
exit(1)
# 文件导出
file_expose_params = {
"request_id": str(uuid.uuid4()),
"input": {
"writing_result_path": file_path,
"writing_result_type": "html_url"
},
"parameters": {}
}
response = requests.post(file_expose_url, json=file_expose_params, headers=headers)
if response.status_code == HTTPStatus.OK:
print("file exported successfully.")
export_info = response.json()["output"]["result"]
return export_info
else:
print(f'code={response.status_code}')
exit(1)
if __name__ == "__main__":
if len(sys.argv) != 2:
print("usage: python deep_search_demo.py <file_path>")
exit(1)
file_path = sys.argv[1]
export_info = get_file_export_info(file_path)
print(json.dumps(export_info, indent=2, ensure_ascii=False))