I created free AI API
Posted by EeeMoon@reddit | Python | View on Reddit | 19 comments
Perchance.org provides free image and text generators, but there's no API. So I created a small package that allows you to integrate AI in your project.
Source: https://github.com/eeemoon/perchance
What my project does? It provides Python interface for generating images and text on perchance.org.
Note that this is DIY API, so it's not recommended to use it in production.
soggyiteration6595@reddit
Wow, this is awesome! I've always been fascinated with the potential of AI in creative projects. I remember trying to create a text generator a while back, and it was quite a challenge. Excited to check out this DIY API for generating images and text on perchance.org. Can't wait to see what kind of content I can come up with using this tool! Do you have any ideas on how you would use it in a project? honeygf\~com
brutalformation78@reddit
Wow, this is super cool! I've always been fascinated by AI and its applications in creative fields like generating images and text. Reminds me of a project I worked on where we used similar technology for a chatbot. Have you had a chance to test out this API yet? I'm curious to know how user-friendly it is and if you've seen any interesting results from it.
completememory8@reddit
Wow, this is so cool! I love how technology continues to advance, making it easier for us to incorporate AI into our projects. I have been wanting to delve into AI programming, and this seems like a great starting point. Have any of you already tried using this package? Any tips or cool results to share? Can't wait to explore this further!
alternatingarrears2@reddit
Wow, this is so cool! I love using AI tools in my projects, and having a DIY API for generating images and text sounds like a dream come true. I can't wait to try it out! Have you been able to use it in any projects yet? How did it go?
KingsmanVince@reddit
I would use an URL parser instead of string concatenation like this
tehsilentwarrior@reddit
Reasoning?
Sounds to me like trying to use a nuclear bomb to kill a mosquito kind of thing. Happy to be proven wrong
ofiuco@reddit
Don't ever underestimate what people will do when given a free text input.
tehsilentwarrior@reddit
You mean the dev who will fill in the base url and that also has full control of the code (free text input being the editor)?
ofiuco@reddit
I mean the users of this package whose inputs are going to be handled this way.
No_Indication_1238@reddit
There is no user input being handled here. The BASE_URL is hardcoded in the child class. If you can modify that, you can modify everything in the codebase. Defending the use of a url parser in this situation is like asking a person to wear a bullet proof vest because he might shoot himself with his own gun.
tehsilentwarrior@reddit
The users of the base url are the devs
Bobofey@reddit
It seems like it could be overkill to me as well, but I guess it can be used to throw an exception if the base url is not formatted correctly. It can also avoid the possibility of double forward slashes when constructing the URL
HommeMusical@reddit
Adding a dependency in order to prevent a single, very obvious string concatenation doesn't seem like a great idea.
(Also, a URL parser is something that parses URLs into their component parts, but we know what you meant.)
kuzmovych_y@reddit
urllib.parse.urljoin
is built-in. It is a nit, but not unreasonable.Bobofey@reddit
Why?
FloxaY@reddit
weirdest nit
marvinv1@reddit
I get a runtime error while running the text generator
RuntimeError: asyncio.run() cannot be called from a running event loop
LactatingBadger@reddit
Are you running this in a Jupyter notebook? Jupyter itself runs in an event loop, so just run
await main()
directly.RachelIf@reddit
This sounds like a fantastic resource!