|
3 | 3 |
|
4 | 4 | Graphs are scraping pipelines aimed at solving specific tasks. They are composed by nodes which can be configured individually to address different aspects of the task (fetching data, extracting information, etc.). |
5 | 5 |
|
6 | | -There are currently three types of graphs available in the library: |
| 6 | +There are three types of graphs available in the library: |
7 | 7 |
|
8 | 8 | - **SmartScraperGraph**: one-page scraper that requires a user-defined prompt and a URL (or local file) to extract information from using LLM. |
9 | 9 | - **SearchGraph**: multi-page scraper that only requires a user-defined prompt to extract information from a search engine using LLM. It is built on top of SmartScraperGraph. |
10 | 10 | - **SpeechGraph**: text-to-speech pipeline that generates an answer as well as a requested audio file. It is built on top of SmartScraperGraph and requires a user-defined prompt and a URL (or local file). |
11 | 11 |
|
| 12 | +With the introduction of `GPT-4o`, two new powerful graphs have been created: |
| 13 | + |
| 14 | +- **OmniScraperGraph**: similar to `SmartScraperGraph`, but with the ability to scrape images and describe them. |
| 15 | +- **OmniSearchGraph**: similar to `SearchGraph`, but with the ability to scrape images and describe them. |
| 16 | + |
12 | 17 | .. note:: |
13 | 18 |
|
14 | 19 | They all use a graph configuration to set up LLM models and other parameters. To find out more about the configurations, check the :ref:`LLM` and :ref:`Configuration` sections. |
15 | 20 |
|
| 21 | +OmniScraperGraph |
| 22 | +^^^^^^^^^^^^^^^^ |
| 23 | + |
| 24 | +.. image:: ../../assets/omniscrapergraph.png |
| 25 | + :align: center |
| 26 | + :width: 90% |
| 27 | + :alt: OmniScraperGraph |
| 28 | +| |
| 29 | +
|
| 30 | +First we define the graph configuration, which includes the LLM model and other parameters. Then we create an instance of the OmniScraperGraph class, passing the prompt, source, and configuration as arguments. Finally, we run the graph and print the result. |
| 31 | +It will fetch the data from the source and extract the information based on the prompt in JSON format. |
| 32 | + |
| 33 | +.. code-block:: python |
| 34 | +
|
| 35 | + from scrapegraphai.graphs import OmniScraperGraph |
| 36 | +
|
| 37 | + graph_config = { |
| 38 | + "llm": {...}, |
| 39 | + } |
| 40 | +
|
| 41 | + omni_scraper_graph = OmniScraperGraph( |
| 42 | + prompt="List me all the projects with their titles and image links and descriptions.", |
| 43 | + source="https://perinim.github.io/projects", |
| 44 | + config=graph_config |
| 45 | + ) |
| 46 | +
|
| 47 | + result = omni_scraper_graph.run() |
| 48 | + print(result) |
| 49 | +
|
| 50 | +OmniSearchGraph |
| 51 | +^^^^^^^^^^^^^^^ |
| 52 | + |
| 53 | +.. image:: ../../assets/omnisearchgraph.png |
| 54 | + :align: center |
| 55 | + :width: 80% |
| 56 | + :alt: OmniSearchGraph |
| 57 | +| |
| 58 | +
|
| 59 | +Similar to OmniScraperGraph, we define the graph configuration, create multiple of the OmniSearchGraph class, and run the graph. |
| 60 | +It will create a search query, fetch the first n results from the search engine, run n OmniScraperGraph instances, and return the results in JSON format. |
| 61 | + |
| 62 | +.. code-block:: python |
| 63 | +
|
| 64 | + from scrapegraphai.graphs import OmniSearchGraph |
| 65 | +
|
| 66 | + graph_config = { |
| 67 | + "llm": {...}, |
| 68 | + } |
| 69 | +
|
| 70 | + # Create the OmniSearchGraph instance |
| 71 | + omni_search_graph = OmniSearchGraph( |
| 72 | + prompt="List me all Chioggia's famous dishes and describe their pictures.", |
| 73 | + config=graph_config |
| 74 | + ) |
| 75 | +
|
| 76 | + # Run the graph |
| 77 | + result = omni_search_graph.run() |
| 78 | + print(result) |
| 79 | +
|
16 | 80 | SmartScraperGraph |
17 | 81 | ^^^^^^^^^^^^^^^^^ |
18 | 82 |
|
|
0 commit comments