this post was submitted on 19 Jul 2024
3 points (100.0% liked)

Perchance - Create a Random Text Generator

416 readers
4 users here now

⚄︎ Perchance

This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.

Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)

This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.

See this post for the Complete Guide to Posting Here on the Community!

Rules

1. Please follow the Lemmy.World instance rules.

2. Be kind and friendly.

  • Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)

3. Be thankful to those who try to help you.

  • If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don't manage to help you solve your problem - remember that they're spending time out of their day to try to help a stranger :)

4. Only post about stuff related to perchance.

  • Please only post about perchance related stuff like generators on it, bugs, and the site.

5. Refrain from requesting Prompts for the AI Tools.

  • We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (text-to-image-plugin and ai-text-plugin) e.g. "What is the good prompt for X?", "How to achieve X with Y generator?"
  • See Perchance AI FAQ for FAQ about the AI tools.
  • You can ask for help with prompting at the 'sister' community Casual Perchance, which is for more casual discussions.
  • We will still be helping/answering questions about the plugins as long as it is related to building generators with them.

6. Search through the Community Before Posting.

  • Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.

founded 1 year ago
MODERATORS
top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 3 months ago (1 children)

You can check out the Perchance FAQ which talks about a question about open source Perchance and more, but here's an explanation:

Will there be an open-source Perchance library for programmers? Ideally, yes. The only reason there isn't one already is because Perchance was built in a very "MVP" manner. (Talking to the programmers here,) I've altered the prototypes of inbuilt objects (Array, String, etc.), inadvisably hacked together Proxys and with statements to construct fake scopes and execution chains, simulated operator overloading by playing with valueOf and well-known Symbols, used eval unreservedly, and, in general, summoned every other JavaScript demon needed in order to get the Perchance DSL's syntax to work nicely (all code inside square brackets is executed as plain JavaScript, for those who missed that). So currently Perchance isn't in a state where it's easy to pull out the engine, throw it into an NPM module and call it a day (until this proposal becomes a reality, that is). If you're okay with the aforementioned mess, then you can pretty much just grab the .js files that are used in the iframe, include them in your project and use them the same way they're used in the iframe html (you just pass createPerchanceTree your a string of perchance code and it returns the "root" of the tree, which you can then use to call the sublists).

— Perchance FAQ

[–] perchance 3 points 3 months ago (1 children)

Yep - core engine code is completely open source, though the code is extremely messy as mentioned in the above quote. Also mentioned above, the ShadowRealms will solve that (by isolating the messiness so it doesn't affect the rest of your codebase), and that spec is finally making significant progress lately. A few random notes:

  • Probably the most annoying thing that's not open source at the moment is the AI plugin stuff. It wouldn't be hard to edit the AI plugin code to just use an external API service, but this is unfortunately not feasible for a lot of people because AI stuff is expensive. There are various workarounds, including setting up local models (e.g. using ollama + ComfyUI/A1111 + etc), and maybe eventually even local models within the browser (see Transformers.js) but for now this is just not very easy, and you need a powerful GPU. Still, I'd like to see someone in the community try to play around with these ideas. Note that Perchance exclusively uses open-source models for the AI stuff, so you can replicate all the capabilities by just using top models from civit/localllama/etc.

  • The express.js and mongodb server would be very simple for someone to make. It'd be very hard for me to open source the actual server (and also the AI plugin servers), since it would expose various defence-in-depth abuse-prevention methods, and I'd need to disentangle it from various things like my Cloudflare account (workers, caching rules, etc.), Deno Deploy, B2 Backblaze, and a bunch of other stuff. There are a lot of moving parts that wouldn't be needed for self-hosting, which is why it'd be way easier for someone from the community just built it from scratch. It wouldn't need to be much more than a "hello world" example of express.js and mongodb - basically connect it to this the bare-bones "offline editor": https://www.reddit.com/r/perchance/comments/yi0twl/dev_you_can_now_edit_your_downloaded_generators/ - see also: https://perchance.org/better-offline-editor

  • This may be useful depending on your use case: https://perchance.org/diy-perchance-api

  • There have been a few projects which try to replicate a subset of the Perchance engine in other languages - https://pypi.org/project/PyChance - https://crates.io/crates/purrchance - there may be others.

[–] [email protected] 1 points 3 months ago

That is a very neat explanation! Would be very useful for someone who wants to deep dive into the deepest sides of Perchance. And actually, I'd be interested in learning more on that, too.