Skip to main content

PGA GPT Tools

A collection of tools for PGA AI projects. This repository contains various utilities designed to enhance automation and provide advanced AI capabilities for different applications.

Tools

  • Generate Image: Create images from textual descriptions using the OpenAI DALL-E 3 model.
  • Remove Background: Remove the background from images for better focus on the subject.
  • Web Scrape: Scrape web content from given URLs and extract specific HTML elements.
  • Web Search: Perform web searches using SerpAPI and return comprehensive search results.
  • Get Okta User: Lookup a user by email from your Okta account.

Installation

Clone the repository and install dependencies using pipenv:

git clone https://github.com/pgahq/pga-gpt-tools.git
cd pga-gpt-tools
pipenv install

Environment Variables

To use the tools effectively, you need to set the following environment variables:

  • SERPAPI_API_KEY: Your SerpAPI API key for web search.
  • FIRECRAWL_API_KEY: Your FireCrawl API key for web scrape.
  • OPENAI_API_KEY: Your OpenAI API key for image generation using DALL-E 3.
  • FALAI_API_KEY: Your fal.ai API key for image transformations.
  • OKTA_API_KEY: Your Okta API key for user lookups.
  • OKTA_DOMAIN: Your Okta org domain.

You can manage these environment variables by creating a .env file in the root of your project (for development environments) or setting them up in your CI/CD pipeline.

Example .env File

SERPAPI_API_KEY=your_serpapi_api_key_here
FIRECRAWL_API_KEY=your_firecrawl_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
FALAI_API_KEY=your_falai_api_key_here
OKTA_API_KEY=your_okta_api_key_here
OKTA_DOMAIN=your_okta_domain_here

Load the .env file in your script using python-dotenv:

Loading Environment Variables

from dotenv import load_dotenv
import os

load_dotenv()

Loading Environment Variables from AWS SSM

Alternatively, you can load these environment variables directly from AWS SSM Parameters. Ensure you have the necessary permissions to access these SSM parameters.

Example SSM Helper

import boto3

def ssm_get(parameter_name):
    ssm = boto3.client('ssm')
    response = ssm.get_parameter(
        Name=parameter_name,
        WithDecryption=True
    )
    if 'Parameter' in response:
        if 'Value' in response['Parameter']:
            return response['Parameter']['Value']
    return None

Loading Environment Variables

import os
from src.helpers import ssm_get

os.environ['SERPAPI_API_KEY'] = ssm_get('/pga-gpt/serpapi_api_key')
os.environ['FIRECRAWL_API_KEY'] = ssm_get('/pga-gpt/firecrawl_api_key')
os.environ['OPENAI_API_KEY'] = ssm_get('/pga-gpt/openai_api_key')
os.environ['FALAI_API_KEY'] = ssm_get('/pga-gpt/falai_api_key')
os.environ['OKTA_API_KEY'] = ssm_get('/pga-gpt/okta_api_key')
os.environ['OKTA_DOMAIN'] = ssm_get('/pga-gpt/okta_domain')

Usage

Import All Tools

You can import all tools in a single statement:

from pga_gpt_tools import GenerateImage, RemoveBackground, WebScrape, WebSearch, GetOktaUser

Import Individual Tools

Generate Image

from pga_gpt_tools.generate_image import GenerateImage

tool = GenerateImage(prompt="A scenic view of mountains during sunset")
image_details = tool.run()
print(image_details)

Remove Background

from pga_gpt_tools.remove_background import RemoveBackground

tool = RemoveBackground(image_url="https://example.com/image.jpg")
result = tool.run()
print(result)

Web Scrape

from pga_gpt_tools.web_scrape import WebScrape

tool = WebScrape(url="https://www.example.com", element="title")
scraped_content = tool.run()
print(scraped_content)
from pga_gpt_tools.web_search import WebSearch

tool = WebSearch(query="PGA Championship 2023")
search_results = tool.run()
print(search_results)

Get Okta User

from pga_gpt_tools.get_okta_user import GetOktaUser

tool = GetOktaUser(email="test@pgahq.invalid")
user_results = tool.run()
print(user_results)

Development

Setting Up

First, clone the repository and navigate into the project directory:

git clone https://github.com/pgahq/pga-gpt-tools.git
cd pga-gpt-tools

Installing Dependencies

Install dependencies using pipenv:

pipenv install

Running Tests

Run tests to ensure everything is working correctly:

pipenv run pytest

Contributing

We welcome contributions from the community! To contribute:

  1. Create a new branch (git checkout -b my-feature-branch).
  2. Make your changes and commit them (git commit -am 'Add new feature').
  3. Push the feature branch to origin (git push origin my-feature-branch).
  4. Create a new Pull Request into main.

Guidelines

  • Ensure your code follows the PEP 8 style guide.
  • Write tests for any new features or changes.
  • Make sure all tests pass before submitting a PR.

Continuous Integration and Deployment

This repository uses CircleCI for continuous integration and deployment. Packages are automatically deployed to PyPI when PRs are merged into the main branch.

Metadata

Release files for pga-gpt-tools 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pga-gpt-tools 0.1.1
File Size Uploaded
pga_gpt_tools-0.1.1.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pga-gpt-tools 0.1.1
File Interpreter ABI Platform
pga_gpt_tools-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / pga_gpt_tools-0.1.1.tar.gz

Download URL pga_gpt_tools-0.1.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
451b50c645cc054342ad539d06beaf0408f470d8b201a8462399735ba9f8ca84
BLAKE2b-256 checksum
How to use checksums
f92aa12d2289395609c1e6ac566e5537f5e7bb10ca0701e67b3f8e675e51854b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.18

Release files / pga_gpt_tools-0.1.1-py3-none-any.whl

Download URL pga_gpt_tools-0.1.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d3a2c4e9ffb4584ac392c0e93dcbb06888069106656eb598cb1ea374661dffe
BLAKE2b-256 checksum
How to use checksums
4c169129e2bc506b0760a64f2d9f7f459798641508cd72236f99b32edee3faea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page