Skip to content

Instantly share code, notes, and snippets.

@vhxs
Last active August 12, 2023 17:30
Show Gist options
  • Save vhxs/aeb90ecc1bd7a214e7b98c1255405013 to your computer and use it in GitHub Desktop.
Save vhxs/aeb90ecc1bd7a214e7b98c1255405013 to your computer and use it in GitHub Desktop.
Using LangChain's question answering capability to ask questions about what I post on Mastodon
from langchain.document_loaders import MastodonTootsLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.vectorstores.utils import filter_complex_metadata
loader = MastodonTootsLoader(mastodon_accounts=["@[email protected]"], number_toots=300)
documents = loader.load()
documents = filter_complex_metadata(documents)
index = VectorstoreIndexCreator().from_documents(documents)
print(index.query("What kinds of interests does this user have?"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment