|
| 1 | +--- |
| 2 | +title: '🦐 Phidata' |
| 3 | +description: 'Build AI Assistants with ScrapeGraph using Phidata' |
| 4 | +--- |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +[Phidata](https://www.phidata.com) is a development framework for building production-ready AI Assistants. This integration allows you to easily add ScrapeGraph's web scraping capabilities to your Phidata-powered AI agents. |
| 9 | + |
| 10 | +<Card |
| 11 | + title="Official Phidata Documentation" |
| 12 | + icon="book" |
| 13 | + href="https://docs.phidata.com/introduction" |
| 14 | +> |
| 15 | + Learn more about building AI Assistants with Phidata |
| 16 | +</Card> |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +Install the required packages: |
| 21 | + |
| 22 | +```bash |
| 23 | +pip install -U phidata |
| 24 | + |
| 25 | +pip install scrapegraph-py |
| 26 | +``` |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +### Basic Example |
| 31 | + |
| 32 | +Create an AI Assistant with ScrapeGraph tools: |
| 33 | + |
| 34 | +```python |
| 35 | +from phi.agent import Agent |
| 36 | +from phi.tools.scrapegraph_tools import ScrapeGraphTools |
| 37 | + |
| 38 | +# Initialize with smartscraper enabled |
| 39 | +scrapegraph = ScrapeGraphTools(smartscraper=True) |
| 40 | + |
| 41 | +# Create an agent with the tools |
| 42 | +agent = Agent( |
| 43 | + tools=[scrapegraph], |
| 44 | + show_tool_calls=True, |
| 45 | + markdown=True, |
| 46 | + stream=True |
| 47 | +) |
| 48 | + |
| 49 | +# Use smartscraper to extract structured data |
| 50 | +agent.print_response(""" |
| 51 | +Use smartscraper to extract the following from https://www.wired.com/category/science/: |
| 52 | +- News articles |
| 53 | +- Headlines |
| 54 | +- Images |
| 55 | +- Links |
| 56 | +- Author |
| 57 | +""") |
| 58 | +``` |
| 59 | + |
| 60 | +### Markdown Conversion |
| 61 | + |
| 62 | +You can also use ScrapeGraph to convert web pages to markdown: |
| 63 | + |
| 64 | +```python |
| 65 | +from phi.agent import Agent |
| 66 | +from phi.tools.scrapegraph_tools import ScrapeGraphTools |
| 67 | + |
| 68 | +# Initialize with only markdownify enabled |
| 69 | +scrapegraph_md = ScrapeGraphTools(smartscraper=False) |
| 70 | + |
| 71 | +# Create an agent for markdown conversion |
| 72 | +agent_md = Agent( |
| 73 | + tools=[scrapegraph_md], |
| 74 | + show_tool_calls=True, |
| 75 | + markdown=True |
| 76 | +) |
| 77 | + |
| 78 | +# Convert webpage to markdown |
| 79 | +agent_md.print_response( |
| 80 | + "Fetch and convert https://www.wired.com/category/science/ to markdown format" |
| 81 | +) |
| 82 | +``` |
| 83 | + |
| 84 | +## Features |
| 85 | + |
| 86 | +<CardGroup cols={2}> |
| 87 | + <Card title="Smart Scraping" icon="robot"> |
| 88 | + Extract structured data using natural language |
| 89 | + </Card> |
| 90 | + <Card title="Markdown Conversion" icon="file-code"> |
| 91 | + Convert web pages to clean markdown |
| 92 | + </Card> |
| 93 | + <Card title="Streaming Support" icon="stream"> |
| 94 | + Real-time responses with streaming |
| 95 | + </Card> |
| 96 | + <Card title="Tool Visibility" icon="eye"> |
| 97 | + Debug with visible tool calls |
| 98 | + </Card> |
| 99 | +</CardGroup> |
| 100 | + |
| 101 | +## Support |
| 102 | + |
| 103 | +Need help with the integration? |
| 104 | + |
| 105 | +<CardGroup cols={2}> |
| 106 | + <Card |
| 107 | + title="Phidata Discord" |
| 108 | + icon="discord" |
| 109 | + href="https://discord.gg/4MtYHHrgA8" |
| 110 | + > |
| 111 | + Join the Phidata community |
| 112 | + </Card> |
| 113 | + <Card |
| 114 | + title="GitHub Cookbook" |
| 115 | + icon="github" |
| 116 | + href="https://github.com/phidatahq/phidata/blob/main/cookbook/tools/scrapegraph_tools.py" |
| 117 | + > |
| 118 | + Check out the source code |
| 119 | + </Card> |
| 120 | +</CardGroup> |
0 commit comments