No project description provided
Project description
🎾 MastodonFetcher Node for Haystack
This custom component for Haystack is designed to fetch the latest posts from a given Mastodon username and return the contents as a list of Haystack Documents. This way, it can be used as a replacement for a retriever node in a pipeline.
Instllation
For Haystack 2.0-Beta onwards:
pip install mastodon-fetcher-haystack
For Haystack 1.x
pip install mastodon-fetcher-haystack==0.0.1
Usage in Haystack 2.0-Beta onwards
- The node expects a full Mastodon username as the
usernameinput. E.g. 'tuana@sigmoid.social'. - You can set the number of posts you want to retrieve by setting the
last_k_postsparameter while initializing the MastodonFetcher, or in therunmethod. This can be a maximum of 40.
from mastodon_fetcher_haystack.mastodon_fetcher import MastodonFetcher
mastodon_fetcher = MastodonFetcher()
mastodon_fetcher.run(username="tuana@sigmoid.social")
In a pipeline
from haystack import Pipeline
from mastodon_fetcher_haystack.mastodon_fetcher import MastodonFetcher
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders import PromptBuilder
prompt_builder = PromptBuilder(template='YOUR_PROMPT_TEMPLATE')
llm = OpenAIGenerator(api_key'YOUR_OPENAI_API_KEY')
pipe = Pipeline()
pipe.add_component("fetcher", mastodon_fetcher)
pipe.add_component("prompt_builder", prompt_builder)
pipe.add_component("llm", llm)
pipe.connect("fetcher.documents", "prompt_builder.documents")
pipe.connect("prompt_builder.prompt", "llm.prompt")
pipe.run(data={"fetcher": {"username": "tuana@sigmoid.social"}})
Usage in Haystack 1.x
- The node expects a full Mastodon username as the
queryinput. E.g. 'tuana@sigmoid.social'. - You can set the number of posts you want to retrieve by setting the
last_k_postsparameter while initializing the MastodonFetcher, or in therunmethod. This can be a maximum of 40.
from mastodon_fetcher_haystack.mastodon_fetcher import MastodonFetcher
mastodon_fetcher = MastodonFetcher()
mastodon_fetcher.run(query="tuana@sigmoid.social")
In a pipeline
from haystack import Pipeline
from mastodon_fetcher_haystack.mastodon_fetcher import MastodonFetcher
mastodon_fetcher = MastodonFetcher(last_k_posts=15)
prompt_node = PromptNode(default_prompt_template="YOUR_PROMPT_TEMPLATE", model_name_or_path="text-davinci-003", api_key="YOUR_API_KEY")
pipeline = Pipeline()
pipeline.add_node(component=mastodon_fetcher, name="MastodonFetcher", inputs=["Query"])
pipeline.add_nide(component=prompt_node, name="PromptNode", inputs=["MastodonFetcher"])
pipeline.run(query="tuana@sigmoid.social")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mastodon_fetcher_haystack-0.1.0.tar.gz.
File metadata
- Download URL: mastodon_fetcher_haystack-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.26.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a838535e38925eb5a33e8ff4137432c81a5b6bc18e22c5e9659d209fa105a110
|
|
| MD5 |
f0bce47239cf17cf523e7dfb5c81e9c0
|
|
| BLAKE2b-256 |
e3af5d051987aa4e93aa705377ec2c2e8e94480f689514faff2e65f4abaa9096
|
File details
Details for the file mastodon_fetcher_haystack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mastodon_fetcher_haystack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.26.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f4125213d29b67f5f17b2cca18e1feea6ee373cbb7833a648da860e98f1afd4
|
|
| MD5 |
7f42decfdf66d04012ac4060d332d504
|
|
| BLAKE2b-256 |
ee428bc108cc3ff24de6dead76f34f185317415be35319d3b97e60843611a2c3
|