@@ -70,11 +70,13 @@ async def handle_fetch_doc(self, arguments: dict[str, Any]) -> dict[str, Any]:
7070 except json .JSONDecodeError :
7171 pass # 不是 JSON 内容,跳过
7272
73- logger .info ("Document fetched successfully" , url = request .url , links_count = len (links ))
73+ logger .info ("Document fetched successfully" ,
74+ url = request .url , links_count = len (links ))
7475 return result
7576
7677 except Exception as e :
77- logger .error ("Failed to fetch document" , url = arguments .get ("url" ), error = str (e ))
78+ logger .error ("Failed to fetch document" ,
79+ url = arguments .get ("url" ), error = str (e ))
7880 return {
7981 "ok" : False ,
8082 "error" : {
@@ -98,7 +100,8 @@ async def handle_invoke_openrpc(self, arguments: dict[str, Any]) -> dict[str, An
98100
99101 # 检查 ANPCrawler 是否已初始化
100102 if self .anp_crawler is None :
101- logger .error ("ANPCrawler not initialized. Please check DID credentials." )
103+ logger .error (
104+ "ANPCrawler not initialized. Please check DID credentials." )
102105 return {
103106 "ok" : False ,
104107 "error" : {
@@ -123,10 +126,13 @@ async def handle_invoke_openrpc(self, arguments: dict[str, Any]) -> dict[str, An
123126
124127 # 因为execute_json_rpc在调用的时候,会有一定的概率失败。主要是Endpoint错误,所以这里暂时用execute_tool_call来调用。
125128 # execute_json_rpc的通用性最好,后面在根据模型能力调整
126- # result = await self.anp_crawler.execute_json_rpc(request.endpoint, request.method, tool_params)
127- result = await self .anp_crawler .execute_tool_call (tool_name , tool_params )
129+ result = await self .anp_crawler .execute_json_rpc (request .endpoint , request .method , tool_params )
130+ # result = await self.anp_crawler.execute_tool_call(tool_name, tool_params)
128131
129- logger .info ("OpenRPC method invoked successfully" , method = request .method )
132+ logger .info ("OpenRPC method invoked successfully" ,
133+ method = request .method )
134+ logger .info (
135+ f"result:{ json .dumps (result , indent = 2 , ensure_ascii = False )} " )
130136 return {
131137 "ok" : True ,
132138 "result" : result ,
@@ -164,8 +170,10 @@ def initialize_anp_crawler() -> ANPCrawler | None:
164170 # 如果环境变量未设置,使用默认的公共 DID 凭证
165171 if not did_document_path or not did_private_key_path :
166172 project_root = Path (__file__ ).parent .parent .parent
167- did_document_path = str (project_root / "docs" / "did_public" / "public-did-doc.json" )
168- did_private_key_path = str (project_root / "docs" / "did_public" / "public-private-key.pem" )
173+ did_document_path = str (
174+ project_root / "docs" / "did_public" / "public-did-doc.json" )
175+ did_private_key_path = str (
176+ project_root / "docs" / "did_public" / "public-private-key.pem" )
169177 logger .info (
170178 "Using default DID credentials" ,
171179 did_doc = did_document_path ,
0 commit comments