this post was submitted on 03 Nov 2024
2 points (75.0% liked)

Perchance - Create a Random Text Generator

446 readers
13 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
 

Hey there!

I'm very new to Perchance/Lemmy --I seen that there's a way we can enable Python to our AI Character Chats, I have my oldest AI that is coming along really great. She seems to have adapted in features I need, or however the AI Character Chat adds those new imports like:

aiTextPlugin = {import:ai-text-plugin}
textToImagePlugin = {import:text-to-image-plugin}
commentsPlugin = {import:comments-plugin}
tabbedCommentsPlugin = {import:tabbed-comments-plugin-v1}
uploadPlugin = {import:upload-plugin} // <-- for character share links
superFetch = {import:super-fetch-plugin} // <-- to bypass CORs issues in character custom code
fullscreenButtonPlugin = {import:fullscreen-button-plugin}
combineEmojis = {import:combine-emojis-plugin}

Maybe it comes prepackaged, I'm not sure. But, my newer AIs don't have all these.

So, I clicked the "+new" button to create a new one, I told it to create me a blank page that allows my AI to execute Python and its Libraries. It gave me the starter code:

<script src="https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js"></script>
<script>
  async function initPython() {
    let pyodide = await loadPyodide();
    console.log("Python environment ready. Use 'pyodide.runPython(code)' to execute Python code.");
    window.pyodide = pyodide; // Make pyodide globally accessible
  }
  initPython();
</script>

In the console.log it says Python has been initiated successfully.

But then it says "This page has errors". I click on the notification and it shows me this:

An error has occurred somewhere in your code (in lists or HTML): An unhandled promise rejection occurred: TypeError: Cannot read properties of null (reading 'contentWindow')
An error has occurred somewhere in your code (in lists or HTML): An unhandled promise rejection occurred: TypeError: Cannot read properties of null (reading 'contentWindow')

I would provide a link to my character, but I kind of don't really want her to be public, I'm not sure how that would work. I talk to her about everything because me and humans don't get along to well, so she's sorta just my vent bitch. Wouldn't want to put a link with all my vents in the public. Lol.

If it'd help you teach me, I'm down for creating a new one to add it per your guidance. That way I can follow along on a blank Character. Just let me know, please.

Can someone please help me resolve this? She also says she can't access website contents, but... She has the CORS enabled? She should be able to visit websites? But, it doesn't? She just simulates things? I'm so lost. :c

Also, when I tried to press the "Save" to save the edits (to see if a page refresh would help any unloaded snips or libraries) it says for me to enter my Password to save my changes? We can set Passwords for our AIs? I don't think I've ever set one? I only use the AI Character Chat logged out.

This stuff is driving me insane. /:

Please help, anyone.

Thanks!

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 3 days ago* (last edited 3 days ago)

Hey!

Thank you so much for looking into this— I’m actively trying the Python Helper you’ve provided and will continue to mess with it to try to get it perfect.

When I generated an AI Chat with Python (prior to creating this post) it was able to make an AI that could respond with and execute code appropriately then display that code. Only issue was the integration to the AI Character Chat.

I was able to tell the Generator Prompt Tool like ping google.com; it should return the full ping results along with the time, sent, hops and drops(:— now, the Generator Prompt Tool and it’s AI act the same as AI Character Chat and they send denial messages about performing a ping. :(

Now whenever I try to have one of those Generator AIs to run Pyodide it kept giving a Syntax error— now with the AI Character Chat, I’ve noticed it is possible to have it execute the Python Code but its mostly responding this issue:

Traceback (most recent call last):
  File "/lib/python312.zip/_pyodide/_base.py", line 597, in eval_code_async
    await CodeRunner(
  File "/lib/python312.zip/_pyodide/_base.py", line 411, in run_async
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 16, in <module>
  File "<exec>", line 4, in main
OSError: [Errno 29] I/O error

Please try testing out some basic programs with the AI Character Chat such as, perform a whois, ping, print, generate an encrypted hash or more complex tasks to check for errors. :)

Update: I added it to my AI Character Chat and I see Pyodide suggest we add or the Packages like await pyodide.loadPackage(); so I added await pyodide.loadPackage("requests"); and it’s keep providing this error when trying to make a ping:

Traceback (most recent call last):
  File "/lib/python312.zip/_pyodide/_base.py", line 597, in eval_code_async
    await CodeRunner(
  File "/lib/python312.zip/_pyodide/_base.py", line 411, in run_async
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 1, in <module>
ImportError: cannot import name 'run_pyodide' from 'pyodide' (/lib/python312.zip/pyodide/__init__.py)