• 8 Posts
  • 115 Comments
Joined 1 year ago
cake
Cake day: July 14th, 2023

help-circle
  • As a general strategy for parsing stuff out of free-form/natural language, I’d definitely recommend using the AI text generation rather than regex, since natural language is so diverse that regex will fail a lot of the time. In most cases there are too many different ways that things can be said to be able to capture them all with regex.

    I assume you’re talking about perchance.org/ai-character-chat custom code, and if so, you could do something like this:

    function scanDescription(description) {
      let result = await oc.getInstructCompletion({ // oc.getInstructCompletion is the /ai-character-chat custom code equivalent to perchance's ai text plugin
        instruction: `Convert the following description into a JSON object like this: { lastName, race, politicalEntity, rank, position }\nDESCRIPTION: ${description}\n\nRespond with just the one-line JSON object, and nothing more.`,
        startWith: `{ "lastName":`, // make it start off with the correct format (to ensure it doesn't e.g. say "sure! I can help you with that...")
        stopSequences: ["}"], // force it to stop at the end of the JSON, just in case it doesn't stop by itself (e.g. tries to say "there you go!" or something)
      });
      return JSON.parse(result.text);
    }
    
    // Example usage:
    
    let info = "Nick, a 49-year-old man, is from a small farming town in Iowa. His last name is Young, he is human, and he holds the rank of Captain in the local police force. His political entity is the United States.";
    
    let result = await scanDescription(info);
    
    console.log(result.politicalEntity);
    console.log(result.lastName);
    // ...
    

    More info on custom code for perchance.org/ai-character-chat is here: https://rentry.org/82hwif




  • (Note that Perchance is actually a platform for creating generators/applications, and it sounds like you’re talking about one particular generator, made by one particular user - namely perchance.org/ai-character-chat - in this case I happen to be that ‘user’. This is just a heads up because a lot of people who land here think that perchance is an AI chat site or whatever. It’s actually a platform where anyone can create random generators, and other things like AI chat applications)

    it just… Goes “stupid”?

    when I make more advanced AIs it tells me they can’t access websites or show me the contents.

    it’ll run through the Lore Querying then it doesn’t provide its “Generated Response” in regards to the facts in the Lores.

    I can probably fix all of these things, but I need example threads where they happened. If any of them happen again and if you’re able to share (in reply here, or via DM) a snapshot of a thread using this save button:

    then I should be able to work out what’s happening and fix it. Without example threads, it’s really hard for me to fix stuff like this. But the moment someone gives me an example thread/export, or an easy way to consistently reproduce the issue, I can usually fix/improve it really fast.

    This Generator Has Errors

    Are you able to explain the steps I can take to reproduce this error? I just created a character, and added some example lore, and saved it, and it seems to work fine, so it might be related to some settings in your character, or something like that. If you’re not able to reliably reproduce it (i.e. it happens randomly), then another helpful thing would be to click that “this generator has errors” notice and copy/screenshot the error message that is shown.




  • Thanks!

    1. I’ve hackily fixed <a href="#foo">foo</a> clicks so they work properly now.

    2. I’ve also added a fix so if you visit perchance.org/whatever#foo it’ll correctly try to scroll to the id="foo" element if it exists: https://perchance.org/dkp9npcidc#foo - pinging @VioneT@lemmy.world

    3. You can also type a hash into the address bar of an already loaded page and press enter, and it’ll scroll to the element, like a normal top-level page does.

    4. I’ve also fixed history.replaceState so you can now change the query string of the top-level frame as shown below. It’ll throw an error if you try to change the pathname, since that could allow for malicious ‘spoofing’ of other generators as mentioned above.

    history.replaceState({}, "", `/${generatorName}?foo=1`)
    
    1. You can change the hash with window.location.hash = "#foo" (you can also do this with replaceState IIUC).
    2. You can change page/tab title with document.title = "foo"; and it’ll propagate to the top-level frame.
    3. You can change the favicon like you usually would (add a <link rel="icon" href="https://exampe.com/image.png"> to <head>) and it’ll propagate to the top-level frame.

    Let me know if you find any bugs 👍

    And I’ve added a hideGalleryButtons to the text to image plugin.


    • I want to remove the gallery buttons in my plugin pages for example
    • that would reach across into the main perchance.org domain it’s disallowed

    Allowing general-purpose cross-domain access like this is not possible, since it would allow very easy login credential stealing, and stuff like that, but these particular things that you’ve mentioned are good suggestions.

    RE gallery button: You’re talking about the “send to gallery” and the “open gallery” buttons in the menu after clicking the heart button, right? Would something like this work?

    promptData
      prompt = ...
      hideGalleryButtons = true
    

    I have needed history.replaceState before myself, but haven’t gotten around to properly thinking about it. I think it should be fine to allow a generator to change the query parameters and hash (i.e. everything other than the pathname - since otherwise could ‘spoof’ other generators/pages). Can you let me know your specific use case to help me triangulate on a good approach here? Do you specifically need pushState? Or will replaceState do? I’m reluctant to add pushState because it can be used ~maliciously - like the spammy sites that effectively hijack your back button to prevent you from leaving the page (or at least, make it require an extra click or two).













  • I wasn’t sure if it was a good idea to continue posting in that thread or make new one, so I’m making a new one.

    Yep, please create new ones, and feel free to keep re-posting important things once every few weeks to move things up my todo list. Thanks for nudging me on these!

    Introduce copy button in prompt and anti prompt fields for better UX on mobile

    Do you mean in the gallery? Or in the “info” box that shows over the top of a generated image? Or in the place where you type your prompt (e.g. on perchance.org/ai-text-to-image-generator)

    I’ve just added the thumbs up/down on mobile by default, and added some buttons at the top of the feed for visited galleries. What is your use case for search? E.g. mainly for searching though (up to a few thousand images) in your own private gallery, say, or mainly for searching public gallery - i.e. possibly tens of thousands or more.