Skip to content

EliNichols6/MyChatGPT

Repository files navigation

MyChatGPT

MyChatGPT is a project that allows integration of OpenAI's ChatGPT into the Second Life virtual world. With this setup, you can communicate in Second Life via chat commands. The responses generated by ChatGPT are relayed back to the Second Life environment.

System Diagram

alt text

Files in this Repository

  • MyChatGPT.lsl: This is a Second Life LSL script. It listens for chat commands starting with /chatgpt and sends the message following the command to the Python server for processing.

  • lslserver.py: This Python server uses Flask to accept HTTP requests from the LSL script. It processes the requests using OpenAI's ChatGPT API to generate responses.

Setup and Installation

  1. Ensure you have Python 3 installed. You can download it here.

  2. Install the required Python packages:

    pip install Flask openai python-dotenv langchain 
  3. Clone this repository to your local machine.

  4. Set up an OpenAI account and obtain your API key.

  5. Create a .env file in the project root directory and add your OpenAI API key like so:

    OPENAI_API_KEY=your_key_here
    OPENAI_ORGANIZATION=your_key_here
  6. Create a data.pkl file in the root directory and run pickleload.py to allow the server to interact with data.pkl

  7. Create a conversations.db file in the root directory - this will store user conversations

  8. Run the Python server:

    python3 lslserver.py
  9. Upload the MyChatGPT.lsl script to Second Life and attach it to an object.

  10. Replace the URL in MyChatGPT.lsl with your Python server's URL.

  11. Update the top of the lsl script your corresponding userId

Usage

Once you're in Second Life, type a message in the local chat near the object with the LSL script starting with /chatgpt, followed by your question or statement. The ChatGPT-powered NPC will respond accordingly. Responses will remind you how many user messages you've used in the conversation. Current limits are unknown, but it's reccomended to use '/chatgpt clear' to clear the conversation history.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published