aigifmaker-haystack 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ dist/
2
+ __pycache__/
3
+ .pytest_cache/
4
+ .venv/
5
+ *.egg-info/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AI GIF Maker (https://aigifmaker.ai)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: aigifmaker-haystack
3
+ Version: 0.1.0
4
+ Summary: Haystack component for AI GIF Maker (aigifmaker.ai): turn text into animated GIFs in a pipeline
5
+ Project-URL: Homepage, https://aigifmaker.ai/?utm_source=pypi-haystack&utm_medium=package
6
+ Project-URL: Pricing, https://aigifmaker.ai/pricing
7
+ Project-URL: Documentation, https://aigifmaker.readthedocs.io/en/latest/
8
+ Project-URL: Source, https://github.com/hanshs474/aigifmaker-haystack
9
+ Author-email: AI GIF Maker <support@aigifmaker.ai>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: ai,aigifmaker,animated-gif,gif,gif-generator,haystack,pipeline,text-to-gif
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Multimedia :: Graphics
15
+ Requires-Python: >=3.9
16
+ Requires-Dist: aigifmaker>=0.1.1
17
+ Requires-Dist: haystack-ai>=2.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # aigifmaker-haystack
21
+
22
+ Turn text into animated GIFs with AI GIF Maker. Native GIF generation — no video conversion. Type what you want and download your GIF in about a minute.
23
+
24
+ This is a [Haystack](https://haystack.deepset.ai) component for [AI GIF Maker](https://aigifmaker.ai/?utm_source=pypi-haystack&utm_medium=package): drop `AigifmakerGifGenerator` into a pipeline and every prompt comes out as a link to a finished `.gif`.
25
+
26
+ ```bash
27
+ pip install aigifmaker-haystack
28
+ export AIGIFMAKER_API_KEY=sk-... # create one at https://aigifmaker.ai/settings/apikeys
29
+ ```
30
+
31
+ ```python
32
+ from aigifmaker_haystack import AigifmakerGifGenerator
33
+
34
+ AigifmakerGifGenerator().run(prompt="a corgi in sunglasses dancing on a beach, looping")
35
+ # {"gifs": ["https://.../....gif"]}
36
+ ```
37
+
38
+ ## In a pipeline
39
+
40
+ Let an LLM write the GIF idea, then render it:
41
+
42
+ ```python
43
+ from haystack import Pipeline
44
+ from haystack.components.builders import PromptBuilder
45
+ from haystack.components.generators import OpenAIGenerator
46
+ from aigifmaker_haystack import AigifmakerGifGenerator
47
+
48
+ p = Pipeline()
49
+ p.add_component("brief", PromptBuilder("Write one short GIF prompt reacting to: {{message}}. Say what moves and that it loops."))
50
+ p.add_component("llm", OpenAIGenerator())
51
+ p.add_component("gif", AigifmakerGifGenerator())
52
+ p.connect("brief", "llm")
53
+ p.connect("llm.replies", "gif.prompt")
54
+ ```
55
+
56
+ (`llm.replies` is a list; add a small adapter component that takes `replies[0]` if your Haystack version does not convert it.)
57
+
58
+ ## Component
59
+
60
+ `AigifmakerGifGenerator(api_key=Secret.from_env_var("AIGIFMAKER_API_KEY"), timeout=900.0)`
61
+
62
+ - Input: `prompt` (str), what the GIF shows and how it moves.
63
+ - Output: `gifs`, a list with one GIF URL.
64
+ - Serializes with `to_dict` / `from_dict`; the key stays a Haystack `Secret`.
65
+ - Errors come from the [`aigifmaker`](https://pypi.org/project/aigifmaker/) SDK: `AuthError` (no key or a wrong key), `QuotaError` (out of credits), `RejectedError` (the content filter refused; reword), `GenerationFailed` (the run failed and its credit was refunded).
66
+
67
+ ## Cost
68
+
69
+ Each GIF costs 1 credit on your AI GIF Maker account, the same as on the website. New accounts get one free GIF (it carries a small aigifmaker.ai badge). Credit packs are on the [pricing](https://aigifmaker.ai/pricing?utm_source=pypi-haystack&utm_medium=package) page.
70
+
71
+ Questions: support@aigifmaker.ai. MIT licensed. Source: https://github.com/hanshs474/aigifmaker-haystack
@@ -0,0 +1,52 @@
1
+ # aigifmaker-haystack
2
+
3
+ Turn text into animated GIFs with AI GIF Maker. Native GIF generation — no video conversion. Type what you want and download your GIF in about a minute.
4
+
5
+ This is a [Haystack](https://haystack.deepset.ai) component for [AI GIF Maker](https://aigifmaker.ai/?utm_source=pypi-haystack&utm_medium=package): drop `AigifmakerGifGenerator` into a pipeline and every prompt comes out as a link to a finished `.gif`.
6
+
7
+ ```bash
8
+ pip install aigifmaker-haystack
9
+ export AIGIFMAKER_API_KEY=sk-... # create one at https://aigifmaker.ai/settings/apikeys
10
+ ```
11
+
12
+ ```python
13
+ from aigifmaker_haystack import AigifmakerGifGenerator
14
+
15
+ AigifmakerGifGenerator().run(prompt="a corgi in sunglasses dancing on a beach, looping")
16
+ # {"gifs": ["https://.../....gif"]}
17
+ ```
18
+
19
+ ## In a pipeline
20
+
21
+ Let an LLM write the GIF idea, then render it:
22
+
23
+ ```python
24
+ from haystack import Pipeline
25
+ from haystack.components.builders import PromptBuilder
26
+ from haystack.components.generators import OpenAIGenerator
27
+ from aigifmaker_haystack import AigifmakerGifGenerator
28
+
29
+ p = Pipeline()
30
+ p.add_component("brief", PromptBuilder("Write one short GIF prompt reacting to: {{message}}. Say what moves and that it loops."))
31
+ p.add_component("llm", OpenAIGenerator())
32
+ p.add_component("gif", AigifmakerGifGenerator())
33
+ p.connect("brief", "llm")
34
+ p.connect("llm.replies", "gif.prompt")
35
+ ```
36
+
37
+ (`llm.replies` is a list; add a small adapter component that takes `replies[0]` if your Haystack version does not convert it.)
38
+
39
+ ## Component
40
+
41
+ `AigifmakerGifGenerator(api_key=Secret.from_env_var("AIGIFMAKER_API_KEY"), timeout=900.0)`
42
+
43
+ - Input: `prompt` (str), what the GIF shows and how it moves.
44
+ - Output: `gifs`, a list with one GIF URL.
45
+ - Serializes with `to_dict` / `from_dict`; the key stays a Haystack `Secret`.
46
+ - Errors come from the [`aigifmaker`](https://pypi.org/project/aigifmaker/) SDK: `AuthError` (no key or a wrong key), `QuotaError` (out of credits), `RejectedError` (the content filter refused; reword), `GenerationFailed` (the run failed and its credit was refunded).
47
+
48
+ ## Cost
49
+
50
+ Each GIF costs 1 credit on your AI GIF Maker account, the same as on the website. New accounts get one free GIF (it carries a small aigifmaker.ai badge). Credit packs are on the [pricing](https://aigifmaker.ai/pricing?utm_source=pypi-haystack&utm_medium=package) page.
51
+
52
+ Questions: support@aigifmaker.ai. MIT licensed. Source: https://github.com/hanshs474/aigifmaker-haystack
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "aigifmaker-haystack"
7
+ version = "0.1.0"
8
+ description = "Haystack component for AI GIF Maker (aigifmaker.ai): turn text into animated GIFs in a pipeline"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [{ name = "AI GIF Maker", email = "support@aigifmaker.ai" }]
13
+ keywords = ["haystack", "ai", "gif", "gif-generator", "text-to-gif", "animated-gif", "pipeline", "aigifmaker"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Topic :: Multimedia :: Graphics",
17
+ ]
18
+ dependencies = ["haystack-ai>=2.0", "aigifmaker>=0.1.1"]
19
+
20
+ [project.urls]
21
+ Homepage = "https://aigifmaker.ai/?utm_source=pypi-haystack&utm_medium=package"
22
+ Pricing = "https://aigifmaker.ai/pricing"
23
+ Documentation = "https://aigifmaker.readthedocs.io/en/latest/"
24
+ Source = "https://github.com/hanshs474/aigifmaker-haystack"
25
+
26
+ [tool.hatch.build.targets.wheel]
27
+ packages = ["src/aigifmaker_haystack"]
@@ -0,0 +1,6 @@
1
+ """Haystack component for AI GIF Maker (aigifmaker.ai): turn text into animated GIFs."""
2
+
3
+ from aigifmaker_haystack.generators import AigifmakerGifGenerator
4
+
5
+ __all__ = ["AigifmakerGifGenerator"]
6
+ __version__ = "0.1.0"
@@ -0,0 +1,55 @@
1
+ """AI GIF Maker as a Haystack component.
2
+
3
+ AI GIF Maker (https://aigifmaker.ai) turns text into animated GIFs with native
4
+ GIF generation, no video conversion. The component runs on an AI GIF Maker
5
+ account: pass ``api_key`` (a Haystack ``Secret``) or set ``AIGIFMAKER_API_KEY``.
6
+ Create a key at https://aigifmaker.ai/settings/apikeys. Each GIF costs 1 credit
7
+ on that account, the same as on the website.
8
+ """
9
+
10
+ from typing import Any, Dict, List
11
+
12
+ import aigifmaker
13
+ from haystack import component, default_from_dict, default_to_dict
14
+ from haystack.utils import Secret, deserialize_secrets_inplace
15
+
16
+
17
+ @component
18
+ class AigifmakerGifGenerator:
19
+ """Turns a text prompt into an animated GIF and returns its URL.
20
+
21
+ Usage:
22
+ ```python
23
+ from aigifmaker_haystack import AigifmakerGifGenerator
24
+
25
+ gen = AigifmakerGifGenerator() # reads AIGIFMAKER_API_KEY
26
+ gen.run(prompt="a corgi in sunglasses dancing on a beach, looping")["gifs"]
27
+ ```
28
+ """
29
+
30
+ def __init__(
31
+ self,
32
+ api_key: Secret = Secret.from_env_var("AIGIFMAKER_API_KEY", strict=False),
33
+ timeout: float = 900.0,
34
+ ):
35
+ self.api_key = api_key
36
+ self.timeout = timeout
37
+
38
+ def to_dict(self) -> Dict[str, Any]:
39
+ return default_to_dict(self, api_key=self.api_key.to_dict(), timeout=self.timeout)
40
+
41
+ @classmethod
42
+ def from_dict(cls, data: Dict[str, Any]) -> "AigifmakerGifGenerator":
43
+ deserialize_secrets_inplace(data["init_parameters"], keys=["api_key"])
44
+ return default_from_dict(cls, data)
45
+
46
+ @component.output_types(gifs=List[str])
47
+ def run(self, prompt: str) -> Dict[str, List[str]]:
48
+ """Generate one GIF.
49
+
50
+ Raises an ``aigifmaker.AigifmakerError`` subclass (``AuthError``,
51
+ ``QuotaError``, ``RejectedError``, ``GenerationFailed``) on a refusal,
52
+ an empty balance, a failed run or a timeout.
53
+ """
54
+ url = aigifmaker.generate(prompt, api_key=self.api_key.resolve_value(), timeout=self.timeout)
55
+ return {"gifs": [url]}
@@ -0,0 +1,61 @@
1
+ from unittest import mock
2
+
3
+ import aigifmaker
4
+ import pytest
5
+ from haystack.utils import Secret
6
+ from aigifmaker_haystack import AigifmakerGifGenerator
7
+
8
+
9
+ def test_run_and_roundtrip(monkeypatch):
10
+ monkeypatch.setenv("AIGIFMAKER_API_KEY", "sk-env")
11
+ gen = AigifmakerGifGenerator.from_dict(AigifmakerGifGenerator(timeout=120).to_dict())
12
+ with mock.patch.object(aigifmaker, "generate", return_value="https://cdn.aigifmaker.ai/a.gif") as g:
13
+ assert gen.run(prompt="a corgi") == {"gifs": ["https://cdn.aigifmaker.ai/a.gif"]}
14
+ assert g.call_args.args[0] == "a corgi"
15
+ assert g.call_args.kwargs == {"api_key": "sk-env", "timeout": 120}
16
+
17
+
18
+ def _with_transport(responses):
19
+ seq = iter(responses)
20
+ real = aigifmaker.generate
21
+ t = lambda method, url, body, headers: (200, next(seq))
22
+ return mock.patch.object(aigifmaker, "generate", side_effect=lambda *a, **k: real(*a, transport=t, poll_every=0, **k))
23
+
24
+
25
+ def test_queue_then_success():
26
+ with _with_transport([
27
+ {"code": 0, "data": {"id": "t1", "status": "pending"}},
28
+ {"code": 0, "data": {"id": "t1", "status": "processing", "queued": True, "queueEta": 10}},
29
+ {"code": 0, "data": {"id": "t1", "status": "success", "images": ["https://x/a.gif"]}},
30
+ ]):
31
+ assert AigifmakerGifGenerator(api_key=Secret.from_token("sk")).run(prompt="x") == {"gifs": ["https://x/a.gif"]}
32
+
33
+
34
+ @pytest.mark.parametrize("body,err", [
35
+ ({"code": -1, "message": "invalid API key"}, aigifmaker.AuthError),
36
+ ({"code": 0, "data": {"wall": True, "reason": "anon_credits"}}, aigifmaker.AuthError),
37
+ ({"code": -1, "message": "insufficient credits"}, aigifmaker.QuotaError),
38
+ ({"code": 429, "message": "content cooldown"}, aigifmaker.RejectedError),
39
+ ])
40
+ def test_errors(body, err):
41
+ with _with_transport([body]):
42
+ with pytest.raises(err):
43
+ AigifmakerGifGenerator(api_key=Secret.from_token("sk")).run(prompt="x")
44
+
45
+
46
+ def test_failed():
47
+ with _with_transport([{"code": 0, "data": {"id": "t1"}}, {"code": 0, "data": {"id": "t1", "status": "failed", "errorMessage": "boom"}}]):
48
+ with pytest.raises(aigifmaker.GenerationFailed):
49
+ AigifmakerGifGenerator(api_key=Secret.from_token("sk")).run(prompt="x")
50
+
51
+
52
+ # live smoke, free: no generation happens on either path
53
+ def test_live_wrong_key():
54
+ with pytest.raises(aigifmaker.AuthError):
55
+ AigifmakerGifGenerator(api_key=Secret.from_token("sk-invalidtest000")).run(prompt="smoke test")
56
+
57
+
58
+ def test_live_no_key(monkeypatch):
59
+ monkeypatch.delenv("AIGIFMAKER_API_KEY", raising=False)
60
+ with pytest.raises(aigifmaker.AuthError):
61
+ AigifmakerGifGenerator().run(prompt="smoke test")