Update toolsg

This commit is contained in:
whitney 2025-05-16 17:29:49 -07:00
parent f6c3640b5f
commit 90769ea58a
5 changed files with 23 additions and 4 deletions

View File

@ -37,4 +37,5 @@ def caption_image(input_data):
print(f"Meme created! URL: {meme_url}")
return meme_url
else:
print(f"Meme could not be created. Response code: {result}")
return None

View File

@ -0,0 +1,4 @@
{
"username":"imgflip_username",
"password":"imgflip_password"
}

View File

@ -3,6 +3,7 @@ import requests
import json
def download_image(input_data):
print(f"Downloading image with input data: {input_data}")
input_data = input_data.replace("'", '"')
data = json.loads(input_data)

View File

@ -2,10 +2,11 @@ import requests
GET_MEMES_URL = "https://api.imgflip.com/get_memes"
def get_memes(ignored):
def get_memes(ignored="ignored"):
return get_memes_helper()
def get_memes_helper():
print("Retrieving meme options...")
response = requests.get(GET_MEMES_URL)
result = response.json()

View File

@ -1,8 +1,20 @@
import json
from caption_image import caption_image
from download_image import download_image
from get_memes import get_memes
get_memes()
meme_url = caption_image(20007896, "Top text", "Bottom text")
download_image(meme_url)
# Utilities to determine the template_id
# memes = get_memes()
# print(memes)
# After determining the template_id, manually add it to the below json.
input_data = """
{
"template_id": 87743020,
"text": ["generated meme", "langchain error"]
}
"""
meme_url = caption_image(input_data)
input_data = json.dumps({"url": meme_url})
download_image(input_data)