Skip to content

Commit 0eec93e

Browse files
authored
Merge pull request #672 from ScrapeGraphAI/temp
allignment
2 parents bd2afef + 5d1fe68 commit 0eec93e

File tree

6 files changed

+59
-19
lines changed

6 files changed

+59
-19
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [1.19.0](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.18.3...v1.19.0) (2024-09-13)
2+
3+
4+
### Features
5+
6+
* integration of o1 ([5c25da2](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/5c25da2fe64b4b64a00f1879f3d5dcfbf1512848))
7+
18
## [1.19.0-beta.12](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.19.0-beta.11...v1.19.0-beta.12) (2024-09-14)
29

310

@@ -10,6 +17,7 @@
1017

1118
* added telemetry info ([62912c2](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/62912c263ec7144e2d509925593027a60d258672))
1219

20+
1321
## [1.19.0-beta.11](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.19.0-beta.10...v1.19.0-beta.11) (2024-09-13)
1422

1523

examples/openai/smart_scraper_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
graph_config = {
1919
"llm": {
2020
"api_key": os.getenv("OPENAI_API_KEY"),
21-
"model": "openai/gpt-4o",
21+
"model": "openai/o1-preview",
2222
},
2323
"verbose": True,
2424
"headless": False,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[project]
22
name = "scrapegraphai"
33

4-
54
version = "1.19.0b12"
65

6+
77
description = "A web scraping library based on LangChain which uses LLM and direct graph logic to create scraping pipelines."
88
authors = [
99
{ name = "Marco Vinciguerra", email = "[email protected]" },

scrapegraphai/helpers/models_tokens.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"gpt-4o-2024-08-06": 128000,
2424
"gpt-4o-2024-05-13": 128000,
2525
"gpt-4o-mini":128000,
26-
26+
"o1-preview":128000,
27+
"o1-mini":128000
2728
},
2829
"azure_openai": {
2930
"gpt-3.5-turbo-0125": 16385,
@@ -43,7 +44,9 @@
4344
"gpt-4-32k-0613": 32768,
4445
"gpt-4o": 128000,
4546
"gpt-4o-mini":128000,
46-
"chatgpt-4o-latest": 128000
47+
"chatgpt-4o-latest": 128000,
48+
"o1-preview":128000,
49+
"o1-mini":128000
4750
},
4851
"google_genai": {
4952
"gemini-pro": 128000,

scrapegraphai/utils/copy.py

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
1-
"""
2-
copy module
3-
"""
41
import copy
5-
from typing import Any, Dict, Optional
6-
from pydantic.v1 import BaseModel
2+
from typing import Any
3+
74

85
class DeepCopyError(Exception):
9-
"""Custom exception raised when an object cannot be deep-copied."""
6+
"""
7+
Custom exception raised when an object cannot be deep-copied.
8+
"""
9+
1010
pass
1111

12+
13+
def is_boto3_client(obj):
14+
"""
15+
Function for understanding if the script is using boto3 or not
16+
"""
17+
import sys
18+
19+
boto3_module = sys.modules.get("boto3")
20+
21+
if boto3_module:
22+
try:
23+
from botocore.client import BaseClient
24+
25+
return isinstance(obj, BaseClient)
26+
except (AttributeError, ImportError):
27+
return False
28+
return False
29+
30+
1231
def safe_deepcopy(obj: Any) -> Any:
1332
"""
1433
Attempts to create a deep copy of the object using `copy.deepcopy`
1534
whenever possible. If that fails, it falls back to custom deep copy
1635
logic. If that also fails, it raises a `DeepCopyError`.
17-
36+
1837
Args:
1938
obj (Any): The object to be copied, which can be of any type.
2039
@@ -27,36 +46,40 @@ def safe_deepcopy(obj: Any) -> Any:
2746
"""
2847

2948
try:
49+
3050
return copy.deepcopy(obj)
3151
except (TypeError, AttributeError) as e:
52+
3253
if isinstance(obj, dict):
3354
new_obj = {}
55+
3456
for k, v in obj.items():
3557
new_obj[k] = safe_deepcopy(v)
3658
return new_obj
3759

3860
elif isinstance(obj, list):
3961
new_obj = []
62+
4063
for v in obj:
4164
new_obj.append(safe_deepcopy(v))
4265
return new_obj
4366

4467
elif isinstance(obj, tuple):
4568
new_obj = tuple(safe_deepcopy(v) for v in obj)
69+
4670
return new_obj
4771

4872
elif isinstance(obj, frozenset):
4973
new_obj = frozenset(safe_deepcopy(v) for v in obj)
5074
return new_obj
5175

52-
elif hasattr(obj, "__dict__"):
76+
elif is_boto3_client(obj):
77+
return obj
78+
79+
else:
5380
try:
5481
return copy.copy(obj)
5582
except (TypeError, AttributeError):
56-
raise DeepCopyError(f"Cannot deep copy the object of type {type(obj)}") from e
57-
58-
59-
try:
60-
return copy.copy(obj)
61-
except (TypeError, AttributeError):
62-
raise DeepCopyError(f"Cannot deep copy the object of type {type(obj)}") from e
83+
raise DeepCopyError(
84+
f"Cannot deep copy the object of type {type(obj)}"
85+
) from e

tests/utils/copy_utils_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,9 @@ def test_with_pydantic():
184184
copy_obj = safe_deepcopy(original)
185185
assert copy_obj.value == original.value
186186
assert copy_obj is not original
187+
188+
def test_with_boto3():
189+
import boto3
190+
boto_client = boto3.client("bedrock-runtime", region_name="us-west-2")
191+
copy_obj = safe_deepcopy(boto_client)
192+
assert copy_obj == boto_client

0 commit comments

Comments
 (0)