Skip to content

Commit 1107630

Browse files
committed
add new test for script generator
1 parent 625b0d7 commit 1107630

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

examples/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The model runned for this benchmark is Mistral on Ollama with nomic-embed-text
1313
| Hardware | Example 1 | Example 2 |
1414
| ----------------------- | --------- | --------- |
1515
| Macbook pro 14' m1 | 11.60s | 26.61s |
16-
| Macbook pro 16' m2 max | 8.05s | 12.17 |
16+
| Macbook pro 16' m2 max | 8.05s | 12.17s |
1717

1818
**Note**: the examples on Docker are not runned on other devices than the Macbook because the performance are to slow (10 times slower than Ollama). Indeed the results are the following:
1919

tests/Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
Regarding the tests for the folder graphs and nodes it was created a specific repo as a example
44
([link of the repo](https://github.com/VinciGit00/Scrapegrah-ai-website-for-tests)). The test website is hosted [here](https://scrapegrah-ai-website-for-tests.onrender.com).
5+
Remember to activating Ollama and having installed the LLM on your pc

tests/script_generator_test.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pytest
2+
from scrapegraphai.graphs import ScriptCreatorGraph
3+
from scrapegraphai.utils import prettify_exec_info
4+
5+
6+
@pytest.fixture
7+
def graph_config():
8+
return {
9+
"llm": {
10+
"model": "ollama/mistral",
11+
"temperature": 0,
12+
"format": "json",
13+
"base_url": "http://localhost:11434",
14+
},
15+
"embeddings": {
16+
"model": "ollama/nomic-embed-text",
17+
"temperature": 0,
18+
"base_url": "http://localhost:11434",
19+
}
20+
}
21+
22+
23+
def test_script_creator_graph(graph_config):
24+
# Create the ScriptCreatorGraph instance
25+
smart_scraper_graph = ScriptCreatorGraph(
26+
prompt="List me all the news with their description.",
27+
source="https://perinim.github.io/projects",
28+
config=graph_config
29+
)
30+
31+
# Run the graph
32+
result = smart_scraper_graph.run()
33+
34+
# Check that the result is not empty
35+
assert result is not None
36+
37+
# Get graph execution info
38+
graph_exec_info = smart_scraper_graph.get_execution_info()
39+
40+
# Check that execution info is not empty
41+
assert graph_exec_info is not None
42+
43+
# Check that execution info is a dictionary
44+
assert isinstance(graph_exec_info, dict)
45+
46+
# Print execution info
47+
print(prettify_exec_info(graph_exec_info))

tests/smart_scraper_ollama_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import pytest
55
from scrapegraphai.graphs import SmartScraperGraph
6-
from scrapegraphai.utils import prettify_exec_info
76

87

98
@pytest.fixture

0 commit comments

Comments
 (0)