Skip to content

Commit ddbfbe1

Browse files
committed
Merge branch 'pre/beta' into generate_answer_parallel
2 parents df1ecc0 + 7080a0a commit ddbfbe1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2913
-274
lines changed

.github/update-requirements.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Update requirements
2+
on:
3+
push:
4+
paths:
5+
- 'pyproject.toml'
6+
- '.github/workflows/update-requirements.yml'
7+
8+
jobs:
9+
update:
10+
name: Update requirements
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Install the latest version of rye
14+
uses: eifinger/setup-rye@v3
15+
- name: Build app
16+
run: rye run update-requirements
17+
commit:
18+
name: Commit changes
19+
run: |
20+
git config --global user.name 'github-actions'
21+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
22+
git add .
23+
git commit -m "ci: update requirements.txt [skip ci]"
24+
git push
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,65 @@
1+
## [1.11.0-beta.1](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.10.4...v1.11.0-beta.1) (2024-07-23)
2+
3+
4+
### Features
5+
6+
* add new toml ([fcb3220](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/fcb3220868e7ef1127a7a47f40d0379be282e6eb))
7+
* add nvidia connection ([fc0dadb](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/fc0dadb8f812dfd636dec856921a971b58695ce3))
8+
9+
10+
### Bug Fixes
11+
12+
* **md_conversion:** add absolute links md, added missing dependency ([12b5ead](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/12b5eada6ea783770afd630ede69b8cf867a7ded))
13+
14+
15+
### chore
16+
17+
* **dependecies:** add script to auto-update requirements ([3289c7b](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/3289c7bf5ec58ac3d04e9e5e8e654af9abcee228))
18+
* **ci:** set up workflow for requirements auto-update ([295fc28](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/295fc28ceb02c78198f7fbe678352503b3259b6b))
19+
* update requirements.txt ([c7bac98](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/c7bac98d2e79e5ab98fa65d7efa858a2cdda1622))
20+
* upgrade dependencies and scripts ([74d142e](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/74d142eaae724b087eada9c0c876b40a2ccc7cae))
21+
* **pyproject:** upgrade dependencies ([0425124](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/0425124c570f765b98fcf67ba6649f4f9fe76b15))
22+
23+
24+
### Docs
25+
26+
* add hero image ([4182e23](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/4182e23e3b8d8f141b119b6014ae3ff20b3892e3))
27+
* updated readme ([c377ae0](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/c377ae0544a78ebdc0d15f8d23b3846c26876c8c))
28+
29+
30+
### CI
31+
32+
* **release:** 1.10.0-beta.6 [skip ci] ([254bde7](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/254bde7008b41ffa434925e3ae84340c53a565bd))
33+
* **release:** 1.10.0-beta.7 [skip ci] ([1756e85](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/1756e8522f3874de8afbef9ac327f9b3f1a49d07))
34+
* **release:** 1.10.0-beta.8 [skip ci] ([255e569](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/255e569172b1029bc2a723b2ec66bcf3d3ee3791))
35+
36+
## [1.10.0-beta.8](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.10.0-beta.7...v1.10.0-beta.8) (2024-07-23)
37+
138
## [1.10.4](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.10.3...v1.10.4) (2024-07-22)
239

340

41+
442
### Bug Fixes
543

44+
45+
* **md_conversion:** add absolute links md, added missing dependency ([12b5ead](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/12b5eada6ea783770afd630ede69b8cf867a7ded))
46+
47+
## [1.10.0-beta.7](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.10.0-beta.6...v1.10.0-beta.7) (2024-07-23)
48+
49+
50+
### Features
51+
52+
* add nvidia connection ([fc0dadb](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/fc0dadb8f812dfd636dec856921a971b58695ce3))
53+
54+
55+
### chore
56+
57+
* **dependecies:** add script to auto-update requirements ([3289c7b](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/3289c7bf5ec58ac3d04e9e5e8e654af9abcee228))
58+
* **ci:** set up workflow for requirements auto-update ([295fc28](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/295fc28ceb02c78198f7fbe678352503b3259b6b))
59+
* update requirements.txt ([c7bac98](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/c7bac98d2e79e5ab98fa65d7efa858a2cdda1622))
60+
61+
## [1.10.0-beta.6](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.10.0-beta.5...v1.10.0-beta.6) (2024-07-22)
62+
663
* parse node ([09256f7](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/09256f7b11a7a1c2aba01cf8de70401af1e86fe4))
764

865
## [1.10.3](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.10.2...v1.10.3) (2024-07-22)
@@ -29,8 +86,12 @@
2986
## [1.10.0](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.9.2...v1.10.0) (2024-07-20)
3087

3188

89+
3290
### Features
3391

92+
93+
* add new toml ([fcb3220](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/fcb3220868e7ef1127a7a47f40d0379be282e6eb))
94+
3495
* add gpt4o omni ([431edb7](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/431edb7bb2504f4c1335c3ae3ce2f91867fa7222))
3596
* add searchngx integration ([5c92186](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/5c9218608140bf694fbfd96aa90276bc438bb475))
3697
* refactoring_to_md function ([602dd00](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/602dd00209ee1d72a1223fc4793759450921fcf9))
@@ -43,8 +104,11 @@
43104
* search link node ([cf3ab55](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/cf3ab5564ae5c415c63d1771b32ea68f5169ca82))
44105

45106

107+
46108
### chore
47109

110+
111+
* **pyproject:** upgrade dependencies ([0425124](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/0425124c570f765b98fcf67ba6649f4f9fe76b15))
48112
* correct search engine name ([7ba2f6a](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/7ba2f6ae0b9d2e9336e973e1f57ab8355c739e27))
49113
* remove unused import ([fd1b7cb](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/fd1b7cb24a7c252277607abde35826e3c58e34ef))
50114
* **ci:** upgrade lockfiles ([c7b05a4](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/c7b05a4993df14d6ed4848121a3cd209571232f7))
@@ -68,6 +132,7 @@
68132
* **release:** 1.9.0-beta.5 [skip ci] ([bb62439](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/bb624399cfc3924825892dd48697fc298ad3b002))
69133
* **release:** 1.9.0-beta.6 [skip ci] ([54a69de](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/54a69de69e8077e02fd5584783ca62cc2e0ec5bb))
70134

135+
71136
## [1.10.0-beta.5](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.10.0-beta.4...v1.10.0-beta.5) (2024-07-20)
72137

73138

README.md

Lines changed: 40 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ScrapeGraphAI is a *web scraping* python library that uses LLM and direct graph
1717
Just say which information you want to extract and the library will do it for you!
1818

1919
<p align="center">
20-
<img src="https://raw.githubusercontent.com/VinciGit00/Scrapegraph-ai/main/docs/assets/scrapegraphai_logo.png" alt="Scrapegraph-ai Logo" style="width: 50%;">
20+
<img src="https://raw.githubusercontent.com/VinciGit00/Scrapegraph-ai/main/docs/assets/sgai-hero.png" alt="ScrapeGraphAI Hero" style="width: 100%;">
2121
</p>
2222

2323
## 🚀 Quick install
@@ -26,159 +26,84 @@ The reference page for Scrapegraph-ai is available on the official page of PyPI:
2626

2727
```bash
2828
pip install scrapegraphai
29+
30+
playwright install
2931
```
3032

3133
**Note**: it is recommended to install the library in a virtual environment to avoid conflicts with other libraries 🐱
3234

33-
## 🔍 Demo
34-
Official streamlit demo:
35-
36-
[![My Skills](https://skillicons.dev/icons?i=react)](https://scrapegraph-ai-web-dashboard.streamlit.app)
37-
38-
Try it directly on the web using Google Colab:
39-
40-
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing)
41-
42-
## 📖 Documentation
43-
44-
The documentation for ScrapeGraphAI can be found [here](https://scrapegraph-ai.readthedocs.io/en/latest/).
45-
46-
Check out also the Docusaurus [here](https://scrapegraph-doc.onrender.com/).
47-
4835
## 💻 Usage
49-
There are multiple standard scraping pipelines that can be used to extract information from a website (or local file):
50-
- `SmartScraperGraph`: single-page scraper that only needs a user prompt and an input source;
51-
- `SearchGraph`: multi-page scraper that extracts information from the top n search results of a search engine;
52-
- `SpeechGraph`: single-page scraper that extracts information from a website and generates an audio file.
53-
- `ScriptCreatorGraph`: single-page scraper that extracts information from a website and generates a Python script.
36+
There are multiple standard scraping pipelines that can be used to extract information from a website (or local file).
5437

55-
- `SmartScraperMultiGraph`: multi-page scraper that extracts information from multiple pages given a single prompt and a list of sources;
56-
- `ScriptCreatorMultiGraph`: multi-page scraper that generates a Python script for extracting information from multiple pages given a single prompt and a list of sources.
57-
58-
It is possible to use different LLM through APIs, such as **OpenAI**, **Groq**, **Azure** and **Gemini**, or local models using **Ollama**.
38+
The most common one is the `SmartScraperGraph`, which extracts information from a single page given a user prompt and a source URL.
5939

60-
### Case 1: SmartScraper using Local Models
61-
62-
Remember to have [Ollama](https://ollama.com/) installed and download the models using the **ollama pull** command.
6340

6441
```python
42+
import json
6543
from scrapegraphai.graphs import SmartScraperGraph
6644

45+
# Define the configuration for the scraping pipeline
6746
graph_config = {
6847
"llm": {
69-
"model": "ollama/mistral",
70-
"temperature": 0,
71-
"format": "json", # Ollama needs the format to be specified explicitly
72-
"base_url": "http://localhost:11434", # set Ollama URL
73-
},
74-
"embeddings": {
75-
"model": "ollama/nomic-embed-text",
76-
"base_url": "http://localhost:11434", # set Ollama URL
48+
"api_key": "YOUR_OPENAI_APIKEY",
49+
"model": "gpt-4o-mini",
7750
},
7851
"verbose": True,
52+
"headless": False,
7953
}
8054

55+
# Create the SmartScraperGraph instance
8156
smart_scraper_graph = SmartScraperGraph(
82-
prompt="List me all the projects with their descriptions",
83-
# also accepts a string with the already downloaded HTML code
84-
source="https://perinim.github.io/projects",
57+
prompt="Find some information about what does the company do, the name and a contact email.",
58+
source="https://scrapegraphai.com/",
8559
config=graph_config
8660
)
8761

62+
# Run the pipeline
8863
result = smart_scraper_graph.run()
89-
print(result)
90-
64+
print(json.dumps(result, indent=4))
9165
```
9266

93-
The output will be a list of projects with their descriptions like the following:
67+
The output will be a dictionary like the following:
9468

9569
```python
96-
{'projects': [{'title': 'Rotary Pendulum RL', 'description': 'Open Source project aimed at controlling a real life rotary pendulum using RL algorithms'}, {'title': 'DQN Implementation from scratch', 'description': 'Developed a Deep Q-Network algorithm to train a simple and double pendulum'}, ...]}
97-
```
98-
99-
### Case 2: SearchGraph using Mixed Models
100-
101-
We use **Groq** for the LLM and **Ollama** for the embeddings.
102-
103-
```python
104-
from scrapegraphai.graphs import SearchGraph
105-
106-
# Define the configuration for the graph
107-
graph_config = {
108-
"llm": {
109-
"model": "groq/gemma-7b-it",
110-
"api_key": "GROQ_API_KEY",
111-
"temperature": 0
112-
},
113-
"embeddings": {
114-
"model": "ollama/nomic-embed-text",
115-
"base_url": "http://localhost:11434", # set ollama URL arbitrarily
116-
},
117-
"max_results": 5,
70+
{
71+
"company": "ScrapeGraphAI",
72+
"name": "ScrapeGraphAI Extracting content from websites and local documents using LLM",
73+
"contact_email": "[email protected]"
11874
}
75+
```
11976

120-
# Create the SearchGraph instance
121-
search_graph = SearchGraph(
122-
prompt="List me all the traditional recipes from Chioggia",
123-
config=graph_config
124-
)
77+
There are other pipelines that can be used to extract information from multiple pages, generate Python scripts, or even generate audio files.
12578

126-
# Run the graph
127-
result = search_graph.run()
128-
print(result)
129-
```
79+
| Pipeline Name | Description |
80+
|-------------------------|------------------------------------------------------------------------------------------------------------------|
81+
| SmartScraperGraph | Single-page scraper that only needs a user prompt and an input source. |
82+
| SearchGraph | Multi-page scraper that extracts information from the top n search results of a search engine. |
83+
| SpeechGraph | Single-page scraper that extracts information from a website and generates an audio file. |
84+
| ScriptCreatorGraph | Single-page scraper that extracts information from a website and generates a Python script. |
85+
| SmartScraperMultiGraph | Multi-page scraper that extracts information from multiple pages given a single prompt and a list of sources. |
86+
| ScriptCreatorMultiGraph | Multi-page scraper that generates a Python script for extracting information from multiple pages and sources. |
13087

131-
The output will be a list of recipes like the following:
88+
It is possible to use different LLM through APIs, such as **OpenAI**, **Groq**, **Azure** and **Gemini**, or local models using **Ollama**.
13289

133-
```python
134-
{'recipes': [{'name': 'Sarde in Saòre'}, {'name': 'Bigoli in salsa'}, {'name': 'Seppie in umido'}, {'name': 'Moleche frite'}, {'name': 'Risotto alla pescatora'}, {'name': 'Broeto'}, {'name': 'Bibarasse in Cassopipa'}, {'name': 'Risi e bisi'}, {'name': 'Smegiassa Ciosota'}]}
135-
```
136-
### Case 3: SpeechGraph using OpenAI
90+
Remember to have [Ollama](https://ollama.com/) installed and download the models using the **ollama pull** command, if you want to use local models.
13791

138-
You just need to pass the OpenAI API key and the model name.
92+
## 🔍 Demo
93+
Official streamlit demo:
13994

140-
```python
141-
from scrapegraphai.graphs import SpeechGraph
95+
[![My Skills](https://skillicons.dev/icons?i=react)](https://scrapegraph-ai-web-dashboard.streamlit.app)
14296

143-
graph_config = {
144-
"llm": {
145-
"api_key": "OPENAI_API_KEY",
146-
"model": "gpt-3.5-turbo",
147-
},
148-
"tts_model": {
149-
"api_key": "OPENAI_API_KEY",
150-
"model": "tts-1",
151-
"voice": "alloy"
152-
},
153-
"output_path": "audio_summary.mp3",
154-
}
97+
Try it directly on the web using Google Colab:
15598

156-
# ************************************************
157-
# Create the SpeechGraph instance and run it
158-
# ************************************************
99+
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing)
159100

160-
speech_graph = SpeechGraph(
161-
prompt="Make a detailed audio summary of the projects.",
162-
source="https://perinim.github.io/projects/",
163-
config=graph_config,
164-
)
101+
## 📖 Documentation
165102

166-
result = speech_graph.run()
167-
print(result)
103+
The documentation for ScrapeGraphAI can be found [here](https://scrapegraph-ai.readthedocs.io/en/latest/).
168104

169-
```
105+
Check out also the Docusaurus [here](https://scrapegraph-doc.onrender.com/).
170106

171-
The output will be an audio file with the summary of the projects on the page.
172-
173-
## Sponsors
174-
<div style="text-align: center;">
175-
<a href="https://serpapi.com?utm_source=scrapegraphai">
176-
<img src="https://raw.githubusercontent.com/VinciGit00/Scrapegraph-ai/main/docs/assets/serp_api_logo.png" alt="SerpAPI" style="width: 10%;">
177-
</a>
178-
<a href="https://dashboard.statproxies.com/?refferal=scrapegraph">
179-
<img src="https://raw.githubusercontent.com/VinciGit00/Scrapegraph-ai/main/docs/assets/transparent_stat.png" alt="Stats" style="width: 15%;">
180-
</a>
181-
</div>
182107

183108
## 🤝 Contributing
184109

docs/assets/sgai-hero.png

66.9 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
3+
"""
4+
5+
import os
6+
import pandas as pd
7+
from dotenv import load_dotenv
8+
from scrapegraphai.graphs import CSVScraperMultiGraph
9+
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
10+
11+
load_dotenv()
12+
# ************************************************
13+
# Read the CSV file
14+
# ************************************************
15+
16+
FILE_NAME = "inputs/username.csv"
17+
curr_dir = os.path.dirname(os.path.realpath(__file__))
18+
file_path = os.path.join(curr_dir, FILE_NAME)
19+
20+
text = pd.read_csv(file_path)
21+
22+
# ************************************************
23+
# Define the configuration for the graph
24+
# ************************************************
25+
26+
graph_config = {
27+
"llm": {
28+
"api_key": os.getenv("NEMOTRON_APIKEY"),
29+
"model": "nvidia/meta/llama3-70b-instruct",
30+
}
31+
}
32+
33+
# ************************************************
34+
# Create the CSVScraperMultiGraph instance and run it
35+
# ************************************************
36+
37+
csv_scraper_graph = CSVScraperMultiGraph(
38+
prompt="List me all the last names",
39+
source=[str(text), str(text)],
40+
config=graph_config
41+
)
42+
43+
result = csv_scraper_graph.run()
44+
print(result)
45+
46+
# ************************************************
47+
# Get graph execution info
48+
# ************************************************
49+
50+
graph_exec_info = csv_scraper_graph.get_execution_info()
51+
print(prettify_exec_info(graph_exec_info))
52+
53+
# Save to json or csv
54+
convert_to_csv(result, "result")
55+
convert_to_json(result, "result")

0 commit comments

Comments
 (0)