MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / afunc

Method afunc

bmtools/agent/apitool.py:110–127  ·  view source on GitHub ↗
(json_args)

Source from the content-addressed store, hash-verified

108 return params
109
110 async def afunc(json_args):
111 if isinstance(json_args, str):
112 try:
113 json_args = json.loads(json_args)
114 except:
115 return "Your input can not be parsed as json, please use thought."
116 if "tool_input" in json_args:
117 json_args = json_args["tool_input"]
118
119 async with aiohttp.ClientSession() as session:
120 async with session.get(url, params=json_args) as response:
121 if response.status == 200:
122 message = await response.text()
123 else:
124 message = f"Error code {response.status_code}. You can try (1) Change your input (2) Call another function. (If the same error code is produced more than 4 times, please use Thought: I can not use these APIs, so I will stop. Final Answer: No Answer, please check the APIs.)"
125
126 message = message[:self.max_output_len] # TODO: not rigorous, to improve
127 return message
128
129 tool_name = func_url.replace("/", ".").strip(".")
130 str_doc = ''

Callers 1

_arunMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected