|
1 | 1 | from agno.agent import Agent
|
2 | 2 | from agno.tools.apify import ApifyTools
|
3 | 3 |
|
4 |
| -agent = Agent(tools=[ApifyTools()], show_tool_calls=True) |
5 |
| -agent.print_response("Tell me about https://docs.agno.com/introduction", markdown=True) |
| 4 | +# Apify Tools Demonstration Script |
| 5 | +""" |
| 6 | +This script showcases the power of web scraping and data extraction using Apify's Actors (serverless tools). |
| 7 | +The Apify ecosystem has 4000+ pre-built Actors for almost any web data extraction need! |
| 8 | +
|
| 9 | +--- |
| 10 | +Configuration Instructions: |
| 11 | +1. Install required dependencies: |
| 12 | + pip install agno langchain-apify apify-client |
| 13 | +
|
| 14 | +2. Set the APIFY_API_TOKEN environment variable: |
| 15 | + Add a .env file with APIFY_API_TOKEN=your_apify_api_key |
| 16 | +--- |
| 17 | +
|
| 18 | +Tip: Check out the Apify Store (https://apify.com/store) to find tools for almost any web scraping or data extraction task. |
| 19 | +""" |
| 20 | + |
| 21 | +# Create an Apify Tools agent with versatile capabilities |
| 22 | +agent = Agent( |
| 23 | + name="Web Insights Explorer", |
| 24 | + instructions=[ |
| 25 | + "You are a sophisticated web research assistant capable of extracting insights from various online sources. " |
| 26 | + "Use the available tools for your tasks to gather accurate, well-structured information." |
| 27 | + ], |
| 28 | + tools=[ |
| 29 | + ApifyTools( |
| 30 | + actors=[ |
| 31 | + "apify/rag-web-browser", |
| 32 | + "compass/crawler-google-places", |
| 33 | + "clockworks/free-tiktok-scraper", |
| 34 | + ] |
| 35 | + ) |
| 36 | + ], |
| 37 | + show_tool_calls=True, |
| 38 | + markdown=True, |
| 39 | +) |
| 40 | + |
| 41 | + |
| 42 | +def demonstrate_tools(): |
| 43 | + print("Apify Tools Exploration 🔍") |
| 44 | + |
| 45 | + # RAG Web Search Demonstrations |
| 46 | + print("\n1.1 🕵️ RAG Web Search Scenarios:") |
| 47 | + prompt = "Research the latest AI ethics guidelines from top tech companies. Compile a summary from at least 3 different sources comparing their approaches using RAG Web Browser." |
| 48 | + agent.print_response(prompt, show_full_reasoning=True) |
| 49 | + |
| 50 | + print("\n1.2 🕵️ RAG Web Search Scenarios:") |
| 51 | + prompt = "Carefully extract the key introduction details from https://docs.agno.com/introduction" # Extract content from specific website |
| 52 | + agent.print_response(prompt) |
| 53 | + |
| 54 | + # Google Places Demonstration |
| 55 | + print("\n2. Google Places Crawler:") |
| 56 | + prompt = "Find the top 5 highest-rated coffee shops in San Francisco with detailed information about each location" |
| 57 | + agent.print_response(prompt) |
| 58 | + |
| 59 | + # Tiktok Scraper Demonstration |
| 60 | + print("\n3. Tiktok Profile Analysis:") |
| 61 | + prompt = "Analyze two profiles on Tiktok that lately added #AI (hashtag AI), extracting their statistics and recent content trends" |
| 62 | + agent.print_response(prompt) |
| 63 | + |
| 64 | + |
| 65 | +if __name__ == "__main__": |
| 66 | + demonstrate_tools() |
| 67 | + |
| 68 | +""" |
| 69 | +Want to add a new tool? It's easy! |
| 70 | +- Browse Apify Store |
| 71 | +- Find an Actor that matches your needs |
| 72 | +- Add a new method to ApifyTools following the existing pattern |
| 73 | +- Register the method in the __init__ |
| 74 | +
|
| 75 | +Examples of potential tools: |
| 76 | +- YouTube video info scraper |
| 77 | +- Twitter/X profile analyzer |
| 78 | +- Product price trackers |
| 79 | +- Job board crawlers |
| 80 | +- News article extractors |
| 81 | +- And SO MUCH MORE! |
| 82 | +""" |
0 commit comments