last push from my laptop

This commit is contained in:
nsde 2022-12-30 23:17:42 +01:00
parent 1d62cdf758
commit c732e7d6f4
4 changed files with 34 additions and 20 deletions

View file

@ -8,6 +8,7 @@
- Errors are explained
### Planned
- Start sandbox in another thread, detect print() stuff
- API access (save your API tokens for various services in a `.env` file, and the bot will be able to find out e.g. the weather.)
- Web UI planned (the sandbox has a way higher priority, though! No web UI is going to be worked on before there is no proper sandbox.)
@ -24,6 +25,19 @@ Additionally, never ever, give others access to the sandbox features! Malicious
✅ MacOS (probably - testers needed!)
***
✅ Python 3.8.10+
## Setup
1. Create a `.env` in *this* directory with the following content:
```
OPENAI_API_KEY=sk-ywvx6zhMxWDeQTL69LQMKoBz4Gr26QCAhF6xom9bWUHTuujF
```
2. Replace the value of `OPENAI_API_KEY` with your actual OpenAI API key. The API key above is just an example and doesn't work. Don't give anyone access to anything stored in your `.env`.
3. Then - assuming you already have *Python* and *pip* installed, run `pip install -r requirements.txt`
## Troubleshooting
### `AttributeError: Could not find PyAudio; check installation`
```

19
test.py
View file

@ -1,19 +0,0 @@
# TODO Test this on Windows
import platform
import subprocess
# Check the operating system
os_name = platform.system()
# Set the Discord binary path based on the operating system
if os_name == 'Windows':
discord_path = 'C:\Program Files (x86)\Discord\Discord.exe'
elif os_name == 'Darwin': # macOS
discord_path = '/Applications/Discord.app/Contents/MacOS/Discord'
else:
# Assume Linux
discord_path = '/usr/bin/discord'
# Open Discord using the default binary path
subprocess.run([discord_path])

View file

@ -41,4 +41,23 @@ print(f"{3**4+6*5}")
Human: Tell me a short story.
AI: One day, a kind man named John helped a traveler in need. In return, the traveler gave John a magical stone that brought him good luck and happiness. John used its magic to help others, and the villagers learned to be more compassionate. The end.
Human: Start Discord.
AI:
AI: ```
import os
import platform
import subprocess
# Check the operating system
os_name = platform.system()
# Set the Discord binary path based on the operating system
if os_name == 'Windows':
discord_path = os.getenv('LOCALAPPDATA') + '\\Discord\\Update.exe'
elif os_name == 'Darwin': # macOS
discord_path = '/Applications/Discord.app/Contents/MacOS/Discord'
else: # Assume Linux
discord_path = '/usr/bin/discord'
# Open Discord using the default binary path
subprocess.run([discord_path])
print("Alright. Opening Discord...")
```