wthit56

joined 5 months ago
[–] wthit56 2 points 1 day ago (1 children)

Heads up: that first jpeg link works fine for me.

[–] wthit56 2 points 2 days ago (1 children)

Sounds like it's basically reminding the AI of some data each time a prompt is sent to it. What I do is just put it in the prompt, and it seems to work fine.

Those generators you listed all do the same, reminding the AI of things it needs to know about, but are pretty complex and have a lot to send, most likely. You can make your own Text AI pretty easily, and send whatever you like with the prompt. Maybe try that.

[–] wthit56 6 points 3 days ago

Thanks for the update! I get it. It's a lot of work, and a balancing act for timing things as well. It's hard to live up to (a minor group of) people's expectations. But knowing what the state of play is with an update like this really helps 👍

[–] wthit56 1 points 4 days ago

It's difficult. Because it's generally trying to make one image, building from one idea.

You can try using the BREAK keyword to separate groups of meaning. Like blue hat BREAK yellow dress is more likely to not mix up the colours for the skirt and hat.

[–] wthit56 1 points 5 days ago

The key is, $output is a function. With properties set on that function. So, that requires some sort of build to happen when you first access $output. Your test doesn't have any of that, which is why it works ;p

Here's an example of properties not working correctly on an $output function: https://perchance.org/sqfppqoq6e#edit I did try various tweaks and workarounds. Got something working within the page (can't remember how that worked now) that didn't work when imported. But this example doesn't even work within the page.

[–] wthit56 1 points 5 days ago

In another comment on this post I talked about my own expectations.

And that example I linked to in the post has some very weird behaviour being demonstrated.

[–] wthit56 2 points 5 days ago

Okay understood. Thanks for looking into this for me 👍

[–] wthit56 1 points 1 week ago

Yep that looks good 👍

[–] wthit56 1 points 1 week ago

Thanks for the test. That's what I guessed was happening, yeah... cleared first, processed, then appended. Most likely none of this will change, as it's kinda core and changing it could blow things up. But, for science...

I guess first the expectation/spec should be defined of what "should" happen. This is (or was) my expectation:

  1. Square brackets define a function (the code within the square brackets) and a spot in the HTML.
  2. The function is run.
  3. Its result replaces the spot where the square bracket text used to be.
  4. Update() will do the same process: run the function, and the same spot is replaced with the new result.

(There are of course other ways of defining things. I just don't think it's actually defined by the dev anywhere, but more cludged together--as is the style of perchance. 😉)

So the tricky part here is, in step 3, what happens if the spot no longer exists by the time the function is processed the first time? My expectation:

  • The spot would not be replaced.
  • And if the square brackets don't exist by the time square block processing gets to it the first time, it would not be processed at all and could not be updated--something like that.

If you rewrite the innerHTML/innerText, the old text nodes are disconnected from the DOM. So then you can check if the old ones still have a parent (or the same parent perhaps). If not, don't do the replace step.

Similarly for an update, you could keep a reference to each top-level element created by the code block. Then in the replace step remove as many of them as are still within that same parent, and add the new stuff in at that point--"replacing" it with the result.

I would also expect that if the entire contents of an element is square brackets, the entire contents would be lost on an update. So that would be an easier edge case to process in any case.

I just updated with a test5, which has a more complex case. The result is pretty wild! 😂 I don't know how anyone would've guessed that is the expected behaviour; seems pretty complex. 🫠

[–] wthit56 1 points 1 week ago (2 children)

I know the assignment would return the string also. But then you'd think it would be the same as:

var result_from_square = (test.innerText = "text");
elem.innerHTML = result_from_square;

Which should be doing the same exact thing twice. But it's not, hence the post.

There are other oddities around this as well. Adding Text nodes to the element, and then updating the element which should wipe it... leaves those text nodes there. Stuff like that. It's all likely from the specifics of how it updates and runs square code. And most of the time won't matter. But when it does matter, it's confusing, and needs more and more specialised knowledge about the innards of perchance to even understand what's going on and how to fix it.

 

Example: https://perchance.org/3o1sbun1w3#edit

Seems like what's returned at the end of the square brackets is somehow added, instead of setting what replaces the square brackets. Potentially, it's cleared, then the square brackets are processed, then the result of the square brackets is added?

[–] wthit56 2 points 1 week ago (2 children)

You can use localStorage to save and restore things with code. I believe that's what the remember plugin uses to save things anyway.

So you'd do something like localStorage.setItem("last generated", data.generatedText) which will save it. And when you load, you can use loaded = localStorage.getItem("last generated"); if (loaded) { element.innerText = loaded; } which would put the text in an element with the id "element", if there was anything stored in the first place.

You can look up more about localStorage on MDN.

 

Quite, quite odd. They work fine when used within the page. Just not when imported to another page. Quite frustrating to try to work around, and then find that even the fixes don't work when actually imported elsewhere.

Potentially some subtle bug with the proxies?

 

It should be untouched text. Only in JS does \t etc. are escaped. So \t becomes a tab character instead of just the text \t.

As seen here: https://perchance.org/slash-t-in-textarea-43534#edit

3
submitted 2 weeks ago by wthit56 to c/perchance
 

The <dialog> tag has a built-in backdrop that you can style to hide the page, etc. But that seems to not work on perchance for some reason. Any idea on how to get this to work, and what is blocking the functionality?

 

For example...

The creator of ai-furry-generator was frustrated by their generator now being shown on the page. It has this in the description: "whiteboard drawing with tldraw—powered by Stable Diffusion." Which is fine. (This is what https://lemmy.world/post/23131988 is about.)

But it matches the bad regex /white.*power/i

For now I've told them what to change so it'll show up again. But ideally, it wouldn't match something innocuous like this. Maybe check for only whitespace and dashes, or non-letters, something like that? I mean, some things are going to slip through either way--but personally I'd err on the side of letting good people have good things, rather than taking good things away from good people in case they're bad based on a too-inclusive regex. ;p

Might also be a good idea to console.log every generator that was skipped for showing on the page, with the reason why. So that there's an easy way to see the cause and fix it if it's an invalid match. Or ask the dev to fix that check so it's more correct... without needing to figure out the code itself.

3
[PLUGIN] JSON Stream (self.perchance)
submitted 3 weeks ago* (last edited 3 weeks ago) by wthit56 to c/perchance
 

(By the way this is wthit56. I changed my name to my usual online name, and the one I use in discord.)

https://perchance.org/json-stream-plugin

I've completed work on a plugin to help people make more complex things with AI text.

As always, the plugin page includes full documentation and example code. And I've also made a simple template setup you can use to get started.


Recently, I started playing with AI text--not the AI chat etc. but the plugin itself. I used my AI text demo to try different prompts, experiment with what's possible, etc.

I wanted to do things like have it generate more complex, structured output. Even if it's quite simple, any kind of structure is a bit of a struggle to convince it to generate. And if you do get it to generate the format you wanted, you've still got to parse it anyway to get the separate generated values out. The more structure, the harder it is to handle--especially for the average generator creator on perchance.

It's quite hard to get it to stick to a format you describe--because it's not seen many examples of that format. Unless you use a format it has seen before. I chose JSON, as I'm most familiar with it. Telling it to produce proper/valid JSON works pretty well. And showing it a JSON structure usually gets it to stick to it properly.

And you can have as complex a structure as you need fairly easily.

The next step was, creating a plugin/function that could handle that JSON coming out of the text AI, give you updates as it's built, and easy to use/access values of the generated JSON... to then use to show the user, hide different things, display in different ways any part of the JSON that's been generated.

This plugin took a while to put together. Perhaps there are bugs with it--just let me know. But it's very easy to use, with a number of features that make common uses like creating more HTML ready to take generated values and so on very easy to build out.


If you have ideas this plugin could be used for, I'd love to hear them in the comments of this post. And feel free to ask questions, or put forward ideas for new features you think could benefit people.

1
submitted 1 month ago by wthit56 to c/perchance
 

A button in the top toolbar that adds the generator to your "favourites" list. List is shown in a dropdown, or as icons in the topbar, or on a particular page, etc.

Could be used to collate a "most favourited generators" page.

1
submitted 2 months ago by wthit56 to c/perchance
 

On my generators I have a feedback button in the bottom-right of the window. Now they are covered up by a "Privacy" button that never goes away. 🙄

2
submitted 2 months ago by wthit56 to c/perchance
 

Unsure what the cause is, and it doesn't happen every time.

 

I'm not an AI-chatter myself, but I am still seeing many reports of weirdness.

 

I guess the fix didn't work, mate ;/

2
submitted 4 months ago by wthit56 to c/perchance
 

Helper functions to add and remove children from a Perchance list.

view more: next ›