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.
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.
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
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')
Usage
Import All Tools
You can import all tools in a single statement:
from pga_gpt_tools import GenerateImage, RemoveBackground, WebScrape, WebSearch
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)
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.0.tar.gz
.
File metadata
- Download URL: pga_gpt_tools-0.1.0.tar.gz
- Upload date:
- Size: 5.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 | 4f094714c03b3ceab12a6a2071dd9960667a7ec0b77ae85f282a9d56d8507c6d |
|
MD5 | 1c1dc092d8571172efbc1ddad5820367 |
|
BLAKE2b-256 | 0b91994033f9ca82d4dd3f5e02135338e026632d603b107e4bc73eeea24ee905 |
File details
Details for the file pga_gpt_tools-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pga_gpt_tools-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 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 | 6531590a07d62b9e704d1669b7810c9e887d2cd99ec38727afb63df96cf74572 |
|
MD5 | f4a05b96745e58874e27820541721021 |
|
BLAKE2b-256 | ce374f3e92a6e614dc4004e4dc2fb0f5ca2af21cf2ae4d2a39d4983d4581968f |