10000 GitHub - thecatfix/octo-genarian-agent: A custom ChatGPT assistant that answers your questions in simple, clear language, all set up in GitHub Codespaces
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A custom ChatGPT assistant that answers your questions in simple, clear language, all set up in GitHub Codespaces

Notifications You must be signed in to change notification settings

thecatfix/octo-genarian-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Octogenarian GPT Agent: Simple, Clear Language ChatGPT Assistant

This repository provides a setup guide for creating OctoAgent, a ChatGPT assistant that responds in simple, clear language. OctoAgent uses OpenAI’s latest models (gpt-4 or gpt-3.5-turbo) to answer questions interactively in the terminal. Follow these instructions to fork the repository, set up your OpenAI API key using GitHub Codespaces secrets, and run OctoAgent.


Step 1: Fork This Repository

  1. Fork the Repository:
    • Click the Fork button at the top-right of this page. This will create a copy of the repository under your GitHub account, allowing you to make changes without affecting the original.

Step 2: Set Up Your OpenAI API Key as a Secret in GitHub Codespaces

To keep your OpenAI API key secure, we’ll store it as a secret in GitHub. This way, it won’t appear in any code files, and only you will have access to it in your Codespace.

  1. Get Your OpenAI API Key:

    • Open a new browser tab and go to OpenAI’s API key page.
    • Sign in to your OpenAI account or create one if you haven’t already.
    • Once signed in, locate the API keys section and click Create new secret key.
    • Copy this key (it’s a long string of letters and numbers).
  2. Add the API Key as a Codespace Secret:

    • Go to your forked repository on GitHub.
    • Click on Settings at the top.
    • Scroll down to Secrets and variables and select Codespaces secrets.
    • Click New repository secret.
    • Name the secret OPENAI_API_KEY.
    • Paste your OpenAI API key into the value field.
    • Click Add secret to save it.

    Now, your API key is securely stored and will automatically be available to your Codespaces session.


Step 3: Open the Repository in GitHub Codespaces

  1. Open Codespaces:

    • Go to your forked repository on GitHub.
    • Click the green Code button.
    • Select the Codespaces tab.
    • Click Create Codespace on main.

    This will set up a Codespace, which may take a few moments. Once it’s ready, you’ll see a new page with a code editor and terminal where you can write and run OctoAgent.


Step 4: Write the octoagent.py Script

In this step, you’ll create the octoagent.py file, which contains the code for OctoAgent to connect to ChatGPT.

  1. Create a New File:

    • In your Codespace, look at the File Explorer on the left.
    • Right-click and select New File.
    • Name the file octoagent.py.
  2. Add the Code to octoagent.py:

    • Click on octoagent.py to open it.

    • Copy and paste the following code into the file:

      import os
      import openai
      
      # Load the API key from an environment variable
      openai.api_key = os.getenv('OPENAI_API_KEY')
      
      # Function to ask questions in simple, visual language
      def ask_chatgpt(query):
          """
          Sends a query to ChatGPT and returns a response in simple, clear language.
      
          Parameters:
          query (str): The question or prompt to send to ChatGPT.
      
          Returns:
          str: The response from ChatGPT in simple, clear language.
          """
          # Style prompt for clarity and simplicity
          default_style = "Use simple, visual words and clear, straightforward language that paints a picture."
          styled_query = f"{query}\n\n{default_style}"
      
          # Make API call to OpenAI with the latest model (gpt-4 or gpt-3.5-turbo)
          response = openai.ChatCompletion.create(
              model="gpt-4",  # Use "gpt-3.5-turbo" for a more cost-effective option
              messages=[
                  {"role": "user", "content": styled_query}
              ],
              max_tokens=500
          )
          return response.choices[0].message['content'].strip()
      
      # Main interactive loop
      if __name__ == "__main__":
          while True:
              query = input("Ask OctoAgent a question (or type 'exit' to quit): ")
              if query.lower() == "exit":
                  break
              print(ask_chatgpt(query))

    This code:

    • Loads your OpenAI API key from the secret environment variable.
    • Defines a function, ask_chatgpt, that sends a question to ChatGPT, asking it to respond in simple, clear language.
    • Uses a loop to let you ask multiple questions interactively in the terminal.

Step 5: Install the OpenAI Library in Codespaces

Now, install the OpenAI library so that OctoAgent can connect to ChatGPT.

  1. Install the Library:

    • In the Terminal at the bottom of the Codespaces page, click to activate it (you should see a blinking cursor).
    • Type the following command to install the OpenAI library:
      pip install openai==0.28
    • Press Enter to run the command.

    This command installs the necessary tools to connect OctoAgent to OpenAI.


Step 6: Run OctoAgent

  1. Run the Code:

    • In the Terminal, ensure you’re in the correct folder by typing:
      cd octoagent
    • Run the code by typing:
      python octoagent.py
    • Press Enter.
  2. Ask OctoAgent Questions:

    • After you start the script, you’ll be prompted with: Ask OctoAgent a question (or type 'exit' to quit):.
    • Type your question and press Enter to receive a response from ChatGPT.
    • To exit the loop and stop the program, type exit and press Enter.

How OctoAgent Works

  • OctoAgent connects to OpenAI using your API key (stored securely in Codespaces secrets).
  • It sends questions in a style that requests simple, easy-to-understand answers.
  • You can modify the question in the ask_chatgpt() function in octoagent.py to explore different prompts and responses.

Summary

  • Forked the repository and securely added the OpenAI API key using Codespaces secrets.
  • Opened the repository in GitHub Codespaces and installed the OpenAI library.
  • Wrote and ran OctoAgent to receive responses in simple language.

Now, every time you run octoagent.py, it will securely access your API key from Codespaces secrets and connect to ChatGPT for clear and understandable responses.

About

A custom ChatGPT assistant that answers your questions in simple, clear language, all set up in GitHub Codespaces

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0