Spaces:
Running
Running
from gradio_client import Client | |
import sys | |
import os | |
from dotenv import load_dotenv | |
# 在文件顶部添加 | |
load_dotenv() # 加载环境变量 | |
# 获取 Hugging Face 令牌 | |
hf_token = os.getenv("HF_TOKEN") | |
if not hf_token: | |
print("错误:未找到 HF_TOKEN 环境变量。请设置您的 Hugging Face 令牌。") | |
sys.exit(1) | |
# 修改Client初始化,添加认证令牌 | |
client = Client("MaoShen/Moonshot_DeepResearch", hf_token=hf_token) | |
# First log the user message | |
log_result = client.predict( | |
text_input=""" | |
there is an Startup idea -"Using the reasoning llm to help the startup evaluate their ideas' quality and noveltyn, finally help them imprve their ideas" | |
Do you think this startup idea is of great novelty? research this idea from three perspectives and generate a novelty score: | |
1.Problem Uniqueness: Does this idea address an unmet or unrecognized need? | |
2.Existing Solution: Including competitors (the most important), patent and intellectual property research, and academic research, | |
3. Differentiation: Conduct research from technical innovation, business model innovation, market segment, and user experience. | |
Give your final answer as detailed as professinal as possible in the following format: | |
A Novelty Score on a scale of 100. | |
A report over 5000 words including sections of Overview, Problem Uniqueness, Existing Solution, Differentiation, Conclusion, and Sources & References (show all youe sources); | |
You should have intext Citation in the final answer with number and hyperlink, the hyperlink is a must | |
""", | |
api_name="/log_user_message" | |
) | |
# Then interact with agent using the logged message | |
result = client.predict( | |
messages=[{ | |
"role": "user", | |
"content": log_result, | |
"metadata": { | |
"id": "1", | |
"parent_id": "0" | |
} | |
}], | |
api_name="/interact_with_agent_1" | |
) | |
# 在获取result之后添加以下代码 | |
import json | |
result_file = r"D:\007.Projects\008.deep_research\smolagents\examples\open_deep_research\last_result.json" | |
with open(result_file, 'w', encoding='utf-8') as f: | |
json.dump(result, f, ensure_ascii=False, indent=2) | |
print(f"API响应结果已保存至:{result_file}") | |