From 40fcbe88a4ed8cd090486229c1ef9757f7a0d8cf Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 19:18:49 +0530 Subject: [PATCH 1/8] broswer use with anthropic working fine --- .../ai_meme_generator_browseruse/main.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ai_agent_tutorials/ai_meme_generator_browseruse/main.py diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/main.py b/ai_agent_tutorials/ai_meme_generator_browseruse/main.py new file mode 100644 index 0000000..1c24ee0 --- /dev/null +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/main.py @@ -0,0 +1,37 @@ +import asyncio +from browser_use import Agent, SystemPrompt +from langchain_google_genai import ChatGoogleGenerativeAI +from langchain_openai import ChatOpenAI +from langchain_anthropic import ChatAnthropic + +async def generate_meme(query: str) -> None: + api_key = "A" # Replace with your actual DeepSeek API key + llm = ChatAnthropic( + model="claude-3-5-sonnet-20240620", + api_key=api_key + ) + + task_description = ( + "You are a meme generator expert. You are given a query and you need to generate a meme for it.\n" + "1. Go to https://imgflip.com/memetemplates \n" + "2. Click on the Search bar in the middle and search for ONLY ONE MAIN ACTION VERB (like 'bully', 'laugh', 'cry') in this query: '{0}'\n" + "3. Choose any meme template that metaphorically fits the meme topic: '{0}'\n" + " by clicking on the 'Add Caption' button below it\n" + "4. Write a Top Text (setup/context) and Bottom Text (punchline/outcome) related to '{0}'.\n" + "5. Check the preview making sure it is funny and a meaningful meme. Adjust text directly if needed. \n" + "6. Look at the meme and text on it, if it doesnt make sense, PLEASE retry by filling the text boxes with different text. \n" + "7. Click on the Generate meme button to generate the meme\n" + ).format(query) + + agent = Agent( + task=task_description, + llm=llm, + max_actions_per_step=5, + max_failures=25 + ) + + await agent.run() + +if __name__ == '__main__': + query = "Elon Musk bullying sam altman about trump winning the election" + asyncio.run(generate_meme(query)) From d93ad42c76652c712d426d739d27a712111a1677 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 19:40:06 +0530 Subject: [PATCH 2/8] streamlit inclusion --- .../ai_meme_generator_browseruse/main.py | 58 ++++++++++++++++--- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/main.py b/ai_agent_tutorials/ai_meme_generator_browseruse/main.py index 1c24ee0..2cc96bf 100644 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/main.py +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/main.py @@ -1,11 +1,37 @@ import asyncio +import streamlit as st from browser_use import Agent, SystemPrompt -from langchain_google_genai import ChatGoogleGenerativeAI -from langchain_openai import ChatOpenAI from langchain_anthropic import ChatAnthropic -async def generate_meme(query: str) -> None: - api_key = "A" # Replace with your actual DeepSeek API key +def create_ui() -> tuple[str, str]: + st.title("🎭 AI Meme Generator with Browser Use") + + # Sidebar for API key + with st.sidebar: + st.header("Configuration") + api_key = st.text_input("Enter your Anthropic API Key:", type="password") + + # Main content + st.info(""" + 🤖 This browser agent will help you generate loads of memes by going to imgflip.com and searching for the perfect template for your given query. + """) + + query = st.text_input( + "What would you like to generate a meme for?", + placeholder="Example: India losing against New Zealand in the final of the world cup", + help="Try to be specific and include context for better results" + ) + + return api_key, query + +async def generate_meme(query: str, api_key: str) -> None: + """ + Generates a meme using browser automation. + + Args: + query (str): User's meme request + api_key (str): Anthropic API key + """ llm = ChatAnthropic( model="claude-3-5-sonnet-20240620", api_key=api_key @@ -30,8 +56,26 @@ async def generate_meme(query: str) -> None: max_failures=25 ) - await agent.run() + with st.spinner("🎨 Generating your meme... Please wait"): + await agent.run() + +def main() -> None: + """ + Main function to run the Streamlit app. + """ + st.set_page_config(page_title="AI Meme Generator", page_icon="🎭") + + api_key, query = create_ui() + + if st.button("Generate Meme", disabled=not (api_key and query)): + if not api_key: + st.error("Please enter your Anthropic API key in the sidebar") + return + if not query: + st.error("Please enter what meme you'd like to generate") + return + + asyncio.run(generate_meme(query, api_key)) if __name__ == '__main__': - query = "Elon Musk bullying sam altman about trump winning the election" - asyncio.run(generate_meme(query)) + main() From 8bb26cca49fd1a65467912c2b86263db761d7c71 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 20:13:28 +0530 Subject: [PATCH 3/8] fixes --- .../ai_meme_generator_browseruse/main.py | 60 +++---------------- 1 file changed, 9 insertions(+), 51 deletions(-) diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/main.py b/ai_agent_tutorials/ai_meme_generator_browseruse/main.py index 2cc96bf..e90e275 100644 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/main.py +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/main.py @@ -1,37 +1,11 @@ import asyncio -import streamlit as st from browser_use import Agent, SystemPrompt +from langchain_google_genai import ChatGoogleGenerativeAI +from langchain_openai import ChatOpenAI from langchain_anthropic import ChatAnthropic -def create_ui() -> tuple[str, str]: - st.title("🎭 AI Meme Generator with Browser Use") - - # Sidebar for API key - with st.sidebar: - st.header("Configuration") - api_key = st.text_input("Enter your Anthropic API Key:", type="password") - - # Main content - st.info(""" - 🤖 This browser agent will help you generate loads of memes by going to imgflip.com and searching for the perfect template for your given query. - """) - - query = st.text_input( - "What would you like to generate a meme for?", - placeholder="Example: India losing against New Zealand in the final of the world cup", - help="Try to be specific and include context for better results" - ) - - return api_key, query - -async def generate_meme(query: str, api_key: str) -> None: - """ - Generates a meme using browser automation. - - Args: - query (str): User's meme request - api_key (str): Anthropic API key - """ +async def generate_meme(query: str) -> None: + api_key = "sk-A" # Replace with your actual DeepSeek API key llm = ChatAnthropic( model="claude-3-5-sonnet-20240620", api_key=api_key @@ -47,6 +21,7 @@ async def generate_meme(query: str, api_key: str) -> None: "5. Check the preview making sure it is funny and a meaningful meme. Adjust text directly if needed. \n" "6. Look at the meme and text on it, if it doesnt make sense, PLEASE retry by filling the text boxes with different text. \n" "7. Click on the Generate meme button to generate the meme\n" + "8. Copy the image link and give it as the output\n" ).format(query) agent = Agent( @@ -56,26 +31,9 @@ async def generate_meme(query: str, api_key: str) -> None: max_failures=25 ) - with st.spinner("🎨 Generating your meme... Please wait"): - await agent.run() - -def main() -> None: - """ - Main function to run the Streamlit app. - """ - st.set_page_config(page_title="AI Meme Generator", page_icon="🎭") - - api_key, query = create_ui() - - if st.button("Generate Meme", disabled=not (api_key and query)): - if not api_key: - st.error("Please enter your Anthropic API key in the sidebar") - return - if not query: - st.error("Please enter what meme you'd like to generate") - return - - asyncio.run(generate_meme(query, api_key)) + history = await agent.run() + history.final_result() if __name__ == '__main__': - main() + query = "Elon Musk bullying sam altman about trump winning the election" + asyncio.run(generate_meme(query)) From 5450e8c9fa8d6d7a255e9d074253c7067238bb4f Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 21:20:29 +0530 Subject: [PATCH 4/8] UI additions --- .../ai_meme_generator_browseruse/README.md | 0 .../ai_meme_generator.py | 82 +++++++++++++++++++ .../ai_meme_generator_browseruse/main.py | 39 --------- 3 files changed, 82 insertions(+), 39 deletions(-) create mode 100644 ai_agent_tutorials/ai_meme_generator_browseruse/README.md create mode 100644 ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py delete mode 100644 ai_agent_tutorials/ai_meme_generator_browseruse/main.py diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/README.md b/ai_agent_tutorials/ai_meme_generator_browseruse/README.md new file mode 100644 index 0000000..e69de29 diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py b/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py new file mode 100644 index 0000000..5755ec1 --- /dev/null +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py @@ -0,0 +1,82 @@ +import asyncio +import streamlit as st +from browser_use import Agent, SystemPrompt +from langchain_google_genai import ChatGoogleGenerativeAI +from langchain_openai import ChatOpenAI +from langchain_anthropic import ChatAnthropic +import re + +async def generate_meme(query: str, api_key: str) -> None: + llm = ChatAnthropic( + model="claude-3-5-sonnet-20240620", + api_key=api_key + ) + + task_description = ( + "You are a meme generator expert. You are given a query and you need to generate a meme for it.\n" + "1. Go to https://imgflip.com/memetemplates \n" + "2. Click on the Search bar in the middle and search for ONLY ONE MAIN ACTION VERB (like 'bully', 'laugh', 'cry') in this query: '{0}'\n" + "3. Choose any meme template that metaphorically fits the meme topic: '{0}'\n" + " by clicking on the 'Add Caption' button below it\n" + "4. Write a Top Text (setup/context) and Bottom Text (punchline/outcome) related to '{0}'.\n" + "5. Check the preview making sure it is funny and a meaningful meme. Adjust text directly if needed. \n" + "6. Look at the meme and text on it, if it doesnt make sense, PLEASE retry by filling the text boxes with different text. \n" + "7. Click on the Generate meme button to generate the meme\n" + "8. Copy the image link and give it as the output\n" + ).format(query) + + agent = Agent( + task=task_description, + llm=llm, + max_actions_per_step=5, + max_failures=25 + ) + + history = await agent.run() + + # Extract final result from agent history + final_result = history.final_result() + + # Use regex to find the meme URL in the result + url_match = re.search(r'https://imgflip\.com/i/(\w+)', final_result) + if url_match: + meme_id = url_match.group(1) + # Convert to direct image URL format + return f"https://i.imgflip.com/{meme_id}.jpg" + return None + +def main(): + st.title("AI Meme Generator - Browser Use") + st.info("This AI browser agent does browser automation to generate memes based on your input with browser use. Please enter your API key and describe the meme you want to generate.") + + # Configuration Settings + with st.sidebar: + st.header("⚙️ Configuration Settings") + api_key = st.text_input("Enter your Claude API Key", type="password") + + # Main content area + st.markdown('

🎨 Describe the Meme You Want to Generate

', unsafe_allow_html=True) + query = st.text_input("Enter your meme idea (e.g., 'Ilya's SSI quietly looking at the OpenAI vs Deepseek debate while diligently working on ASI')", "") + + if st.button("Generate Meme"): + if api_key and query: + with st.spinner("🤖 Generating your meme... This might take a minute"): + try: + meme_url = asyncio.run(generate_meme(query, api_key)) + + if meme_url: + st.success("🎉 Meme Generated Successfully!") + st.image(meme_url, caption="Your Generated Meme", use_container_width=True) + + # Display clickable link + st.markdown(f"**Meme Link:** [Open in ImgFlip]({meme_url})") + else: + st.error("Could not retrieve meme URL. Please try again.") + + except Exception as e: + st.error(f"Error generating meme: {str(e)}") + else: + st.warning("⚠️ Please provide both API key and meme idea") + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/main.py b/ai_agent_tutorials/ai_meme_generator_browseruse/main.py deleted file mode 100644 index e90e275..0000000 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/main.py +++ /dev/null @@ -1,39 +0,0 @@ -import asyncio -from browser_use import Agent, SystemPrompt -from langchain_google_genai import ChatGoogleGenerativeAI -from langchain_openai import ChatOpenAI -from langchain_anthropic import ChatAnthropic - -async def generate_meme(query: str) -> None: - api_key = "sk-A" # Replace with your actual DeepSeek API key - llm = ChatAnthropic( - model="claude-3-5-sonnet-20240620", - api_key=api_key - ) - - task_description = ( - "You are a meme generator expert. You are given a query and you need to generate a meme for it.\n" - "1. Go to https://imgflip.com/memetemplates \n" - "2. Click on the Search bar in the middle and search for ONLY ONE MAIN ACTION VERB (like 'bully', 'laugh', 'cry') in this query: '{0}'\n" - "3. Choose any meme template that metaphorically fits the meme topic: '{0}'\n" - " by clicking on the 'Add Caption' button below it\n" - "4. Write a Top Text (setup/context) and Bottom Text (punchline/outcome) related to '{0}'.\n" - "5. Check the preview making sure it is funny and a meaningful meme. Adjust text directly if needed. \n" - "6. Look at the meme and text on it, if it doesnt make sense, PLEASE retry by filling the text boxes with different text. \n" - "7. Click on the Generate meme button to generate the meme\n" - "8. Copy the image link and give it as the output\n" - ).format(query) - - agent = Agent( - task=task_description, - llm=llm, - max_actions_per_step=5, - max_failures=25 - ) - - history = await agent.run() - history.final_result() - -if __name__ == '__main__': - query = "Elon Musk bullying sam altman about trump winning the election" - asyncio.run(generate_meme(query)) From f33f147783b3de97497c788ff40a71575fb4e8f8 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 22:20:24 +0530 Subject: [PATCH 5/8] claude model changed --- .../ai_meme_generator.py | 2 +- .../ai_meme_generator_browseruse/test.py | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ai_agent_tutorials/ai_meme_generator_browseruse/test.py diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py b/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py index 5755ec1..81a0d1e 100644 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py @@ -8,7 +8,7 @@ import re async def generate_meme(query: str, api_key: str) -> None: llm = ChatAnthropic( - model="claude-3-5-sonnet-20240620", + model="claude-3-5-sonnet-20241022", api_key=api_key ) diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/test.py b/ai_agent_tutorials/ai_meme_generator_browseruse/test.py new file mode 100644 index 0000000..38cb890 --- /dev/null +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/test.py @@ -0,0 +1,35 @@ +import asyncio +import os + +from dotenv import load_dotenv +from langchain_openai import ChatOpenAI +from pydantic import SecretStr + +from browser_use import Agent + +# dotenv +load_dotenv() + +api_key = os.getenv('DEEPSEEK_API_KEY', '') +if not api_key: + raise ValueError('DEEPSEEK_API_KEY is not set') + + +async def run_search(): + agent = Agent( + task=('go to amazon.com, search for laptop, sort by best rating, and give me the price of the first result'), + llm=ChatOpenAI( + base_url='https://api.deepseek.com/v1', + model='deepseek-reasoner', + api_key=SecretStr(api_key), + ), + use_vision=False, + max_failures=2, + max_actions_per_step=1, + ) + + await agent.run() + + +if __name__ == '__main__': + asyncio.run(run_search()) \ No newline at end of file From a681894465d4eeee5f6454dc08404588c00ab85c Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 23:03:13 +0530 Subject: [PATCH 6/8] support for more llm models + refined streamlit UI --- .../ai_meme_generator.py | 114 +++++++++++++----- .../requirements.txt | 0 .../ai_meme_generator_browseruse/test.py | 35 ------ 3 files changed, 81 insertions(+), 68 deletions(-) create mode 100644 ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt delete mode 100644 ai_agent_tutorials/ai_meme_generator_browseruse/test.py diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py b/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py index 81a0d1e..7a20191 100644 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/ai_meme_generator.py @@ -1,16 +1,31 @@ import asyncio import streamlit as st from browser_use import Agent, SystemPrompt -from langchain_google_genai import ChatGoogleGenerativeAI from langchain_openai import ChatOpenAI from langchain_anthropic import ChatAnthropic +from langchain_core.messages import HumanMessage import re -async def generate_meme(query: str, api_key: str) -> None: - llm = ChatAnthropic( - model="claude-3-5-sonnet-20241022", - api_key=api_key - ) +async def generate_meme(query: str, model_choice: str, api_key: str) -> None: + # Initialize the appropriate LLM based on user selection + if model_choice == "Claude": + llm = ChatAnthropic( + model="claude-3-5-sonnet-20241022", + api_key=api_key + ) + elif model_choice == "Deepseek": + llm = ChatOpenAI( + base_url='https://api.deepseek.com/v1', + model='deepseek-chat', + api_key=api_key, + temperature=0.3 + ) + else: # OpenAI + llm = ChatOpenAI( + model="gpt-4o", + api_key=api_key, + temperature=0.0 + ) task_description = ( "You are a meme generator expert. You are given a query and you need to generate a meme for it.\n" @@ -29,7 +44,8 @@ async def generate_meme(query: str, api_key: str) -> None: task=task_description, llm=llm, max_actions_per_step=5, - max_failures=25 + max_failures=25, + use_vision=(model_choice != "Deepseek") ) history = await agent.run() @@ -41,42 +57,74 @@ async def generate_meme(query: str, api_key: str) -> None: url_match = re.search(r'https://imgflip\.com/i/(\w+)', final_result) if url_match: meme_id = url_match.group(1) - # Convert to direct image URL format return f"https://i.imgflip.com/{meme_id}.jpg" return None def main(): - st.title("AI Meme Generator - Browser Use") - st.info("This AI browser agent does browser automation to generate memes based on your input with browser use. Please enter your API key and describe the meme you want to generate.") + # Custom CSS styling - # Configuration Settings + + st.title("🤖 AI Meme Generator - Browser Use Web Agent") + st.info("This AI browser agent does browser automation to generate memes based on your input with browser use. Please enter your API key and describe the meme you want to generate.") + + # Sidebar configuration with st.sidebar: - st.header("⚙️ Configuration Settings") - api_key = st.text_input("Enter your Claude API Key", type="password") + st.markdown('', unsafe_allow_html=True) + + # Model selection + model_choice = st.selectbox( + "Select AI Model", + ["Claude", "Deepseek", "OpenAI"], + index=0, + help="Choose which LLM to use for meme generation" + ) + + # API key input based on model selection + api_key = "" + if model_choice == "Claude": + api_key = st.text_input("Claude API Key", type="password", + help="Get your API key from https://console.anthropic.com") + elif model_choice == "Deepseek": + api_key = st.text_input("Deepseek API Key", type="password", + help="Get your API key from https://platform.deepseek.com") + else: + api_key = st.text_input("OpenAI API Key", type="password", + help="Get your API key from https://platform.openai.com") # Main content area - st.markdown('

🎨 Describe the Meme You Want to Generate

', unsafe_allow_html=True) - query = st.text_input("Enter your meme idea (e.g., 'Ilya's SSI quietly looking at the OpenAI vs Deepseek debate while diligently working on ASI')", "") + st.markdown('

🎨 Describe Your Meme Concept

', unsafe_allow_html=True) + + query = st.text_input( + "Meme Idea Input", + placeholder="Example: 'Ilya's SSI quietly looking at the OpenAI vs Deepseek debate while diligently working on ASI'", + label_visibility="collapsed" + ) - if st.button("Generate Meme"): - if api_key and query: - with st.spinner("🤖 Generating your meme... This might take a minute"): - try: - meme_url = asyncio.run(generate_meme(query, api_key)) + if st.button("Generate Meme 🚀"): + if not api_key: + st.warning(f"Please provide the {model_choice} API key") + st.stop() + if not query: + st.warning("Please enter a meme idea") + st.stop() + + with st.spinner(f"🧠 {model_choice} is generating your meme..."): + try: + meme_url = asyncio.run(generate_meme(query, model_choice, api_key)) + + if meme_url: + st.success("✅ Meme Generated Successfully!") + st.image(meme_url, caption="Generated Meme Preview", use_container_width=True) + st.markdown(f""" + **Direct Link:** [Open in ImgFlip]({meme_url}) + **Embed URL:** `{meme_url}` + """) + else: + st.error("❌ Failed to generate meme. Please try again with a different prompt.") - if meme_url: - st.success("🎉 Meme Generated Successfully!") - st.image(meme_url, caption="Your Generated Meme", use_container_width=True) - - # Display clickable link - st.markdown(f"**Meme Link:** [Open in ImgFlip]({meme_url})") - else: - st.error("Could not retrieve meme URL. Please try again.") - - except Exception as e: - st.error(f"Error generating meme: {str(e)}") - else: - st.warning("⚠️ Please provide both API key and meme idea") + except Exception as e: + st.error(f"Error: {str(e)}") + st.info("💡 If using OpenAI, ensure your account has GPT-4o access") if __name__ == '__main__': main() \ No newline at end of file diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt b/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/test.py b/ai_agent_tutorials/ai_meme_generator_browseruse/test.py deleted file mode 100644 index 38cb890..0000000 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/test.py +++ /dev/null @@ -1,35 +0,0 @@ -import asyncio -import os - -from dotenv import load_dotenv -from langchain_openai import ChatOpenAI -from pydantic import SecretStr - -from browser_use import Agent - -# dotenv -load_dotenv() - -api_key = os.getenv('DEEPSEEK_API_KEY', '') -if not api_key: - raise ValueError('DEEPSEEK_API_KEY is not set') - - -async def run_search(): - agent = Agent( - task=('go to amazon.com, search for laptop, sort by best rating, and give me the price of the first result'), - llm=ChatOpenAI( - base_url='https://api.deepseek.com/v1', - model='deepseek-reasoner', - api_key=SecretStr(api_key), - ), - use_vision=False, - max_failures=2, - max_actions_per_step=1, - ) - - await agent.run() - - -if __name__ == '__main__': - asyncio.run(run_search()) \ No newline at end of file From 02dc88348931154a89716730da07075067c9624a Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 23:12:45 +0530 Subject: [PATCH 7/8] added readme and requirements.txt --- .../ai_meme_generator_browseruse/README.md | 51 +++++++++++++++++++ .../requirements.txt | 5 ++ 2 files changed, 56 insertions(+) diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/README.md b/ai_agent_tutorials/ai_meme_generator_browseruse/README.md index e69de29..a5f9ab9 100644 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/README.md +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/README.md @@ -0,0 +1,51 @@ +# 🤖 AI Meme Generator Agent - Browser Automation + +The AI Meme Generator Agent is a powerful browser automation tool that creates memes using AI agents. This app combines multi-LLM capabilities with automated browser interactions to generate memes based on text prompts through direct website manipulation. + +## Features + +- **Multi-LLM Support** + - Claude 3.5 Sonnet (Anthropic) + - GPT-4o (OpenAI) + - Deepseek v3 (Deepseek) + - Automatic model switching with API key validation + +- **Browser Automation**: + - Direct interaction with imgflip.com meme templates + - Automated search for relevant meme formats + - Dynamic text insertion for top/bottom captions + - Image link extraction from generated memes + +- **Smart Generation Workflow**: + - Action verb extraction from prompts + - Metaphorical template matching + - Multi-step quality validation + - Automatic retry mechanism for failed generations + +- **User-Friendly Interface**: + - Model configuration sidebar + - API key management + - Direct meme preview with clickable links + - Responsive error handling + + +API keys required: +- **Anthropic** (for Claude) +- **Deepseek** +- **OpenAI** (for GPT-4o) + +## How to Run + +1. **Clone the Repository**: + ```bash + git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git + cd ai_agent_tutorials/ai_meme_generator_browseruse + ``` +2. **Install the dependencies**: + ```bash + pip install -r requirements.txt + ``` +3. **Run the Streamlit app**: + ```bash + streamlit run ai_meme_generator.py + ``` \ No newline at end of file diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt b/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt index e69de29..2c52e5a 100644 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt @@ -0,0 +1,5 @@ +streamlit +langchain-openai +langchain-anthropic +asyncio +re From 50e28fc091f09c3ade3f49029a74c94184c2a3ec Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 26 Jan 2025 23:17:46 +0530 Subject: [PATCH 8/8] new requirements.txt --- .../ai_meme_generator_browseruse/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt b/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt index 2c52e5a..dd8c43d 100644 --- a/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt +++ b/ai_agent_tutorials/ai_meme_generator_browseruse/requirements.txt @@ -1,4 +1,6 @@ streamlit +browser-use==0.1.26 +playwright==1.49.1 langchain-openai langchain-anthropic asyncio