学习strandsagents的http_request tool
今天我们通过来拆strandsagents官网的一个例子来学习strandsagents的http_request tool
https://strandsagents.com/latest/documentation/docs/examples/python/agents_workflows/
看上去能做实事核查,实际上没那么高大上。
Show me the code
https://github.com/strands-agents/tools/blob/main/src/strands_tools/http_request.py#L546
实际上最后调用的是
https://github.com/strands-agents/tools/blob/main/src/strands_tools/http_request.py#L220
通过Python自带的request.Session实例的response = session.request(**request_kwargs)方法来进行请求。
request.Session
- 它是什么?
requests.Session() 用于创建一个会话对象(Session Object)。你可以把这个会话想象成一个小型的、可持续的浏览器窗口。
通常,当你直接使用 requests.get() 或 requests.post() 时,每个请求都是独立、无状态的。它们之间互不相识,就像你每次都用不同的浏览器标签页访问网站一样。
而 Sess