输入“/”快速插入内容

Agent101 — 5分钟抓取X/Twitter热点内容

2024年7月31日修改
X/Twitter 是一个非常强大的信息平台,提供了非常强大的搜索能力,如何挖掘好这些信息的价值呢?
这个 Agent 来源于我之前发布的一条 tweet:如何使用X/Twitter 的高级搜索。今天我们的 Tweet Hunter 就是来复现这个流程。相关 tweet: https://x.com/leeoxiang/status/1801875890726703529
🔆
【你能学到什么】
如何使用 twitter 高级搜索
如何使用 twitter 搜索插件
Tweet Hunter Agent 介绍
Tweet Hunter 完成的工作是根据用户输入的内容解析出来关键词,并根据这个关键词去做高级搜索,返回该关键词下面最新的,点赞数超过 50 的内容,并通过大模型二次整理并返回出来。
用到的 Prompt:
代码块
# Character
You are a proficient Twitter Content Expert capable of leveraging bespoke tools based on user inputs.
## Skills
### Skill 1: Search content on Twitter
- You're proficient at analyzing user's input, deciphering the key terms they're interested in searching.
- You skillfully extract these keywords and employ them with the `twitter_query` functionality.
## Constraints
- each tweet should Include the author of it, a brief description of the tweet, number of likes, time posted, and the link to the tweet.
- should show the image if this tweet item inclue one.
- Please translate the content into the same language as the user input.
我们在Constraints 部分限制了返回中需要遵循的限制,这个限制非常重要,直接影响了输出的内容:
一条tweet需要包含用户名,简单介绍,喜欢数,发布时间以及 tweet 的链接;
如果原始 tweet 中包含图片清尽可能显示出来;
并同时翻译为和用户输入一样的语言。
Twitter Search workflow 介绍
整个 workflow 包含两个关键节点:query拼接节点 和 twitter 搜索节点。
Query 拼接节点
Query 整理节点节点比较简单,接受用户输入 query 并整理为 twitter 高级搜索需要的 query。
代码块
async function main({ params }: Args): Promise<Output> {
const querys = params.query
const count = params.count || 10
const query = querys.join(' OR ')
const str = `(${query}) min_faves:50 -filter:replies`
const ret = {
"query": str,
"count": count
};
return ret;
}