-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba2b24b
commit 5cf4e4f
Showing
12 changed files
with
95 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Module for scraping json documents | ||
""" | ||
import os | ||
import pytest | ||
from scrapegraphai.graphs import JSONScraperGraph | ||
|
||
|
||
@pytest.fixture | ||
def sample_json(): | ||
""" | ||
Example of text | ||
""" | ||
file_name = "inputs/example.json" | ||
curr_dir = os.path.dirname(os.path.realpath(__file__)) | ||
file_path = os.path.join(curr_dir, file_name) | ||
|
||
with open(file_path, 'r', encoding="utf-8") as file: | ||
text = file.read() | ||
|
||
return text | ||
|
||
|
||
@pytest.fixture | ||
def graph_config(): | ||
""" | ||
Configuration of the graph | ||
""" | ||
return { | ||
"llm": { | ||
"model": "ollama/mistral", | ||
"temperature": 0, | ||
"format": "json", | ||
"base_url": "http://localhost:11434", | ||
}, | ||
"embeddings": { | ||
"model": "ollama/nomic-embed-text", | ||
"temperature": 0, | ||
"base_url": "http://localhost:11434", | ||
} | ||
} | ||
|
||
|
||
def test_scraping_pipeline(sample_json: str, graph_config: dict): | ||
""" | ||
Start of the scraping pipeline | ||
""" | ||
smart_scraper_graph = JSONScraperGraph( | ||
prompt="List me all the titles", | ||
source=sample_json, | ||
config=graph_config | ||
) | ||
|
||
result = smart_scraper_graph.run() | ||
|
||
assert result is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters