Tool

Extract Tweets for LlamaIndex

Load recent tweets from one or more Twitter handles into LlamaIndex documents.

Works with twitterllamaindexlangchain

72
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Ingest tweets from specified Twitter handles into LlamaIndex for further processing or analysis. This asset facilitates the integration of real-time social media data into your AI applications.

Outcomes

What it gets done

01

Connect to the Twitter API using a bearer token.

02

Retrieve a specified number of tweets from given Twitter handles.

03

Load tweet data into LlamaIndex documents.

04

Utilize the loaded data as a tool within LangChain agents.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-twitter | bash

Overview

LlamaIndex Readers Integration: TwitterTweet

A LlamaIndex reader that loads recent tweets from specified Twitter handles via the Twitter API. Use to index and query the recent tweet history of specific accounts, given valid Twitter API access.

What it does

The TwitterTweet Reader loads tweets from a specified Twitter handle into LlamaIndex, retrieving them via the Twitter API. TwitterTweetReader is initialized with a bearer token and a num_tweets cap on how many tweets to pull per handle, and load_data takes a list of twitterhandles to fetch tweets from.

The reader requires access to the Twitter API, which means registering for and obtaining API access through Twitter's developer program before the bearer token can be used.

When to use - and when NOT to

Use it when you want to build a LlamaIndex index or query engine over the recent tweets of one or more specific Twitter accounts - for example, to answer questions about what a handle has been posting about. Do not use it expecting historical tweets beyond what the Twitter API and the configured num_tweets limit return, and it depends entirely on having valid Twitter API access, which is not guaranteed or free to obtain.

Capabilities

load_data fetches up to num_tweets recent tweets for each handle in a given list and returns them as LlamaIndex Document objects.

How to install

pip install llama-index-readers-twitter

Requires a Twitter API bearer token, obtained through Twitter's developer API access program.

Who it's for

Developers building LlamaIndex applications that need to index and query the recent tweet history of specific Twitter accounts.

Source README

LlamaIndex Readers Integration: TwitterTweet

Overview

The TwitterTweet Reader allows you to read tweets of a specified Twitter handle. It retrieves tweets from Twitter using the Twitter API.

Installation

You can install the TwitterTweet Reader via pip:

pip install llama-index-readers-twitter

Check Twitter API on how to get access to twitter API.

Usage

from llama_index.readers.twitter import TwitterTweetReader

### Initialize TwitterTweetReader
reader = TwitterTweetReader(
    bearer_token="<Twitter Bearer Token>", num_tweets=100
)

### Load tweets of user twitter handles
documents = reader.load_data(twitterhandles=["user1", "user2"])

This loader is designed to be used as a way to load data into
LlamaIndex and/or subsequently
used as a Tool in a LangChain Agent.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.