A collection of tools for PGA AI products
Project description
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)
Web Search
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:
- Create a new branch (
git checkout -b my-feature-branch
). - Make your changes and commit them (
git commit -am 'Add new feature'
). - Push the feature branch to origin (
git push origin my-feature-branch
). - 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pga_gpt_tools-0.1.1.tar.gz
.
File metadata
- Download URL: pga_gpt_tools-0.1.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 451b50c645cc054342ad539d06beaf0408f470d8b201a8462399735ba9f8ca84 |
|
MD5 | 87251cfeb713ce8fda35954ab92c382e |
|
BLAKE2b-256 | f92aa12d2289395609c1e6ac566e5537f5e7bb10ca0701e67b3f8e675e51854b |
File details
Details for the file pga_gpt_tools-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pga_gpt_tools-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d3a2c4e9ffb4584ac392c0e93dcbb06888069106656eb598cb1ea374661dffe |
|
MD5 | de71e9fb8be12477cf231f38d1b6fcc1 |
|
BLAKE2b-256 | 4c169129e2bc506b0760a64f2d9f7f459798641508cd72236f99b32edee3faea |