diff
+ Updated Text class
+ Updated Image class
python
"""
class Text(
model: str = "openai",
system: str = "",
contextual: bool = False,
messages: list = [],
seed: int = "random",
jsonMode: bool = False,
...
)
"""
model = pollinations.Text(
model=pollinations.Text.openai(),
system="You are a helpful assistant...",
contextual=True,
messages=[
pollinations.Text.Message(
role="user",
content="What is the capital of France?"
),
pollinations.Text.Message(
role="assistant",
content="The capital of France is Paris."
)
],
seed=42,
jsonMode=True
)
"""
(method) def info(...) -> dict
"""
print(pollinations.Text.openai.info())
"""
(method) def image(
file: str | list,
...
) -> Text
"""
model.image("my_file.png")
print("\n", model(
prompt="What do you see in this image?"
).response)
"""
(method) def __call__(
prompt: str = None,
display: bool = False,
...,
encode: bool = False
) -> Text
"""
response = model(encode=True) use proper encoding
print("\n", response.response, response.time, response.request) The capital of France is Paris., ..., Text.Request(...)
print("\n", model(
prompt="Hello.",
display=True, simulate typing
encode=False
).response)
----------------------------------------------
"""
class Request(
model: str,
prompt: str,
...,
system: str = "",
contextual: bool = False,
messages: List[dict] = None,
seed: str | int = "random",
jsonMode: bool = False
)
"""
"""
class Message(
role: str,
content: str,
images: dict | list = None
)
(method) def image(
file: str,
...
) -> dict
"""
request = pollinations.Text.Request(
model=pollinations.Text.openai(),
prompt="Hello. Whats in this image?",
system="You are a helpful assistant...",
contextual=True,
messages=[
pollinations.Text.Message(
role="user",
content="What is the capital of France?"
),
pollinations.Text.Message(
role="assistant",
content="The capital of France is Paris."
)
],
images=[
pollinations.Text.Message.image("my_file.png"),
pollinations.Text.Message.image("my_file2.png")
],
seed=42,
jsonMode=True
)
print("\n", request(
encode=True
))
python
"""
class Image(
model: str = "flux",
seed: str | int = "random",
width: int = 1024,
height: int = 1024,
enhance: bool = False,
nologo: bool = False,
private: bool = False,
safe: bool = False
)
"""
model = pollinations.Image(
model=pollinations.Image.flux(),
seed="random",
width=1024,
height=1024,
enhance=False,
nologo=False,
private=False,
safe=False
)
"""
(method) def info(...) -> dict
"""
print(pollinations.Image.flux.info())
"""
(method) def __call__(
prompt: str,
*args: Any
) -> Image
"""
image = model(
prompt="A cat with flowers around it."
)
print(image.prompt, image.file)
"""
(method) def save(file: str = "pollinations-image.png") -> Image
"""
image.save(
file="pollinations-image.png"
)
----------------------------------------------
"""
class Request(
model: str = "flux",
prompt: str = "",
seed: str | int = "random",
width: int = 1024,
height: int = 1024,
enhance: bool = False,
nologo: bool = False,
private: bool = False,
safe: bool = False
)
"""
request = pollinations.Image.Request(
model=pollinations.Image.flux(),
prompt="A cat with flowers around it.",
seed="random",
width=1024,
height=1024,
enhance=False,
nologo=False,
private=False,
safe=False
)
print(request)
request()
print(request.prompt, request.response)
Links
- [Pollinations.ai](https://pollinations.ai/)
- [Discord](https://discord.gg/8HqSRhJVxn)
- [Github](https://github.com/pollinations)
- [Repository](https://github.com/pollinations-ai/pollinations.ai)
- [Youtube](https://www.youtube.com/channel/UCk4yKnLnYfyUmCCbDzOZOug)
- [Instagram](https://instagram.com/pollinations_ai)
- [Twitter (X)](https://twitter.com/pollinations_ai)