diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-11-20 19:58:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 19:58:16 +0100 |
commit | ffb4b0d162cc29b1caa4539d854de37206804225 (patch) | |
tree | ea565c46ed908d2a6b4ef3fef1f100e68428aec3 /g4f/Provider/PollinationsAI.py | |
parent | Update api.py (diff) | |
download | gpt4free-ffb4b0d162cc29b1caa4539d854de37206804225.tar gpt4free-ffb4b0d162cc29b1caa4539d854de37206804225.tar.gz gpt4free-ffb4b0d162cc29b1caa4539d854de37206804225.tar.bz2 gpt4free-ffb4b0d162cc29b1caa4539d854de37206804225.tar.lz gpt4free-ffb4b0d162cc29b1caa4539d854de37206804225.tar.xz gpt4free-ffb4b0d162cc29b1caa4539d854de37206804225.tar.zst gpt4free-ffb4b0d162cc29b1caa4539d854de37206804225.zip |
Diffstat (limited to 'g4f/Provider/PollinationsAI.py')
-rw-r--r-- | g4f/Provider/PollinationsAI.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/g4f/Provider/PollinationsAI.py b/g4f/Provider/PollinationsAI.py index 57597bf1..a30f896d 100644 --- a/g4f/Provider/PollinationsAI.py +++ b/g4f/Provider/PollinationsAI.py @@ -3,7 +3,6 @@ from __future__ import annotations from urllib.parse import quote import random import requests -from sys import maxsize from aiohttp import ClientSession from ..typing import AsyncResult, Messages @@ -40,6 +39,7 @@ class PollinationsAI(OpenaiAPI): cls, model: str, messages: Messages, + prompt: str = None, api_base: str = "https://text.pollinations.ai/openai", api_key: str = None, proxy: str = None, @@ -49,9 +49,10 @@ class PollinationsAI(OpenaiAPI): if model: model = cls.get_model(model) if model in cls.image_models: - prompt = messages[-1]["content"] + if prompt is None: + prompt = messages[-1]["content"] if seed is None: - seed = random.randint(0, maxsize) + seed = random.randint(0, 100000) image = f"https://image.pollinations.ai/prompt/{quote(prompt)}?width=1024&height=1024&seed={int(seed)}&nofeed=true&nologo=true&model={quote(model)}" yield ImageResponse(image, prompt) return |