Categories
AI Tech

Add ChatGPT to DBeaver

If you use DBeaver as your SQL IDE, here’s how to add AI right now

What you need

  • DBeaver on version 22.3.5 or higher
  • An OpenAI account and a new API key

Set-Up

Download DBeaver Community Edition https://dbeaver.io/download/

Register for an OpenAI account if you don’t currently have one https://auth0.openai.com/u/signup/

Install DBeaver

Create sample database

You can also access this test database tool through Help > Create Test Database.

“Wait, why do I need the sample database?”

I assume you don’t have a huge personal database ready to go, so save yourself the trouble and have DBeaver spin one up for you.

Another thing to consider before actually using this tool to help you code is that your table header and column names will be sent to OpenAI to help you code. If you or your org have security concerns about this – you probably can’t use this tool with your job.

So instead, create the sample database so you can use the AI without security concerns.

Installing the ChatGPT Add-on

Click Help > Install New Software

In the “Works with” section, type: “DBeaver” and you should see “DBeaver AI” appear in the section below.

Follow the on-screen prompts and restart DBeaver

Open the sample database and press F3

You should see the OpenAI logo to the left of the SQL editor

Click the ChatGPT logo to launch the API and settings window

Go to your OpenAI account and generate a new key and paste it into the API token field

Click “Apply and Close”

Using the Tool

Click the ChatGPT icon again

You will get a prompt asking permission to read the table header and columns. As mentioned above, if you’re not using the sample database, be sure you’re okay with this before proceeding.

With that, you’re off and running…

ChatGPT Output:

SELECT COUNT(*) FROM Album;

Chat GPT Output:

SELECT Genre.Name, COUNT(InvoiceLine.InvoiceId) AS 'Number of Customers'
FROM Genre
INNER JOIN Track ON Genre.GenreId = Track.GenreId
INNER JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId
GROUP BY Genre.Name
ORDER BY COUNT(InvoiceLine.InvoiceId) DESC;

Troubleshooting

Don’t see the OpenAI icon.

  • If you don’t see the icon, confirm that the editor is allowed to run
    • Click Window > Preferences > Editors > AI (ChatGPT)
  • Ensure that “Enable smart completion” is checked.

Don’t have the DBeaver AI package available to install

  • Ensure the DBeaver is updated
    • Help > Check for Update
  • Manually Add the package
    • Click Help > Install New Software > Add
Categories
AI

AI Image Generator

Using Open AI’s image generator

This tutorial explains how to use Open AI’s image generator to create stunning images using Visual Studio Code (VSCode) and Python. I’ll walk you through the process, including how to set up a Python environment, install OpenAI, generate an API key, and use the image generation script. With a few simple steps, you can be up and running in no time, creating and manipulating images with the power of Open AI’s image generator and Python. Have fun and get creative!

Start here if you do not have a Python environment set up already.

I already have a python environment.

For this tutorial, I’ll walk you through the process I completed on my MacBook with VSCode. There are dozens of other Python environments that you can use for this, and of course, you can use your Windows machine (as much as my inner Apple fan-boy doesn’t want you to). Be sure to read the pages linked and follow the instructions carefully as not every code sample can be copied and pasted directly into your terminal to get everything installed.

VSCode installation

PATH set-up

Once you’ve installed VSCode and set-up your PATH, open a new terminal window in VSCode

Install Homebrew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once that finishes, don’t neglect the two steps displayed in the terminal. You’ll need to run two commands which can be copied and pasted, and then run by hitting “return”

Everything that is displayed on the first line that looks like the code below (you’ll see your home directory after the “>>” make sure that you copy that too.)

(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> <your home directory> 

Everything on the second line

eval "$(/opt/homebrew/bin/brew shellenv)"

Installing Python

I do like to complete the “Hello World” Tutorial on a fresh build, but you by no means need to do so.

Upgrade pip

python3.11 -m pip install --upgrade pip

Getting Started with OpenAI

Register for an Open AI Account (if you don’t have one already)

Return to VSCode and Install “OpenAI”

Note: If you’ve set up your environment differently than the steps I outlined above, this input may be different for you

python3 -m pip install openai 

Copy the example code from Open AI (make sure you use the Python script)

import os 
import openai 
openai.organization = "org-Rw9He2WlfsUmXrXLU27JLuPK" openai.api_key = os.getenv("OPENAI_API_KEY") openai.Model.list() 

Two edits I made to this code:

  • Comment out ‘openai.organization’ as I don’t have an Org ID currently
    • If you do sign up for a Team Open AI account, you should update this “org_id”
  • The method that this code is using above is attempting to store your API key in a variable. This is more secure, however since I am the only one using this file, I hardcoded the API key
    • USE CAUTION WITH THIS METHOD IF SHARING THIS SCRIPT WITH OTHERS

The resulting code with edits looks like the following

import os 
import openai 
#openai.organization = "YOUR_ORG_ID" 
openai.api_key = 'YOUR_API_KEY' 
openai.Model.list() 

Generate an API Key in your OpenAI account. Copy and paste that key in between the ‘ ’ in the above code

If you can run this code without an error, you have successfully authenticated and retrieved the Model List

One more change to the code:

  • Comment out ‘openai.Model.list()’ as this is not required for image generation

Retrieve the image generation script from OpenAI

response = openai.Image.create( 
prompt="a white siamese cat", 
n=1, 
size="1024x1024" 
) 
image_url = response['data'][0]['url']

I made another edit for ease of displaying the link

print(response)

Altogether, your code should look like the following (don’t forget to update your API key)

import os
import openai
#openai.organization = "YOUR_ORG_ID"
openai.api_key = 'YOUR_API_KEY'
#openai.Model.list()

#response = openai.Image.create(
  prompt="a baby panda",
  n=1,
  size="1024x1024"
)
image_url = response['data'][0]['url']

print(response)

‘n’ refers to the number of images you would like to generate. This will accept a value from 1-10

‘size’ corresponds to the image dimensions you would like. You can choose between:

  • 256 x 256
  • 512 x 512
  • 1024 x 1024

Generating Images

Now that you have your code compiled, all that’s left is to try it! Get started with the ‘prompt’ by adding your idea in between the “ “ on line 8

prompt = "your great idea here"

Things to Note

  • The images that you generate are only accessible via the URL for one hour, so if you love something, make sure that you download it
  • You have a limited number of calls that you are allotted on your OpenAI account. You can track how many you’ve made here.
  • Another fun use of AI; you can have this code explained to you by pasting it into OpenAI’s chatbot or Denigma (I’ll give them a shout-out since they were my first tool for using AI for code description –
  • Don’t forget that you can use Chat GPT to improve this code. One noticeable improvement would be to have the URL shortened and made easier to open in a web browser.

My favorite image so far

prompt = "a baby panda"
AI-Generated image of a baby panda
Categories
AI

How to backpack the Uncompaghre Wilderness

How to Backpack Uncompahgre: 5 Tips for the First-Time Backpacker

Making the 5+ hour drive just to make it to the trailhead in the Uncompahgre Wildnerness may seem like a daunting task, but I guarantee that it is more than worth it. The drive alone will take you through areas that most Colorado tourists, and residents, never see. The irony? I would argue that west of the Contenital Divide is quintensial Colorado. Iconic landmarks Black Canyon in Gunnison National park, and driving over Monarch Pass. and let’s not forget that if you’re that far west Telluride and Grand Junction aren’t much farther. Let’s talk about the best ways for you to get back into this incredible wildnerness.

How to get to the Uncompahgre Wildnerness

Trailheads for the Uncompahgre can be found all around the small town of Ouray. While a lot of these trails are hiking only, some of the best treks start from Breckenridge, as the Uncompahgre can be accessed right from the Summit. But for our purposes we will be focusing on the area that hugs the western slopes of Telluride and El Jardin. Below you will find a detailed map outlining the trails in the backcountry. You can pick your favorite from our list, or add them if you think they deserve to be included. Trailheads in the Westside (The Area Near Telluride): Cottonwood Trail (A small detour on Lone Tree Trail) Cottonwood Pass (The Big Y and pretty amazing views) Mammoth Trail (Follow the old trail to a campsite near the Cottonwood Pass Trail.

Traveling Tips

1. If you want to start your tour before lunch, choose a hike along the Berdoo Loop. The sign-posting along this trail is relatively good, and the parking lot is close by. However, the trail is on a ridge that is also a creek, so be sure to carry lots of water (otherwise you’ll have to “punch-through” a waterfall) and be ready to take a dip in the Colorado River if you’re in the mood. The trail climbs on for a while and I actually took this trail with a group of Frenchmen from Brittany, and the men were simply un-matchable with their tenacity. They followed the trail like it was a hiking death-trip. In general, they would continue to look back, thinking they were far away from our group, but I knew that they could still see us.

What to Pack

1. Shoes and Heels Now, this might seem obvious, but I am going to stress this point. Yes, you will be hiking a good three to four hours, so make sure that you have a pair of shoes with traction, so that you don’t get hurt in some rocky areas. I know hiking in Chacos and flip flops sounds like a lot of fun, but I assure you that it won’t be. Now if you can’t wear heels, they should be pretty easy to come by. Check out some of my best-selling boot finds below. Brand: Merrell Description: The Westin Kennedy Sandals are ultra flexible, and also super easy to put on and take off. They are sandal compatible and great for wet and muddy conditions. I absolutely adore them. Stretch: 5″ Stratus Stretch Weight: 1.35 oz (38-40 cl) Color: Smoke Style: Women’s 2.

What to Eat

One of the most common concerns in my area is finding nutrition food that isn’t only tasty, but contains a healthy dose of essential vitamins and minerals. When traveling with kids in particular this can be a challenge. “Whole,” natural foods are the best foods to eat. Seeds Seeds are a great source of calories, protein and dietary fiber, making them a great source of calories. Seeds also contain high levels of phytonutrients that aid in improving your immune system, along with providing antioxidants. These help to reduce the impact of outdoor temperatures, and increase your overall resistance to stress and pain. Kale There is no better source of protein in the wilderness than kale. Kale has more protein per ounce than almost any other vegetable.

What to Do

If you’re a winter camper, the challenge is to embrace all the seasons of the year. Good news, we know some good hiking. If you want to try for a big day, pack a big pack and go for a hike. If you are looking to spend a night and set up camp for the night, grab a permit. In recent years there has been an increasing number of permit parking areas. If you are a skilled backpacking backpacker, a series of short hikes and side trips will be more than enough to see this area to its potential. On my next trip I’m hoping to do the full mountain range in a single trip, but that’s up to me. While I personally love doing the big loop around the mountain range, there are many places you can stop for a day hike, or even an overnight.

Conclusion

The Uncompahgre Wildnerness is a place that needs to be preserved. A place with wild trout streams, majestic redrock canyons, and gentle meadows. While you can’t say it is easy to get into the Uncompahgre Wildnerness, it is a special place. If you’re looking for an opportunity to get in there, I think these tips are something to consider. At the end of the day, you get to appreciate the wild beauty of the Uncompahgre. With a little planning and some grit you can find the adventure that awaits. #Wildtopia #WildlifeMonarchTrout #ColoradoTrout A small guide to the Wildnerness and hiking the Rogue Canyon Trail Location: The Uncompahgre Wildnerness is located north of Ouray, about 7 miles west of the town of Telluride.