Skip to content

Commit c717bb6

Browse files
committed
Merge branch 'main' into pre/beta
2 parents cb505ce + 438b812 commit c717bb6

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

scrapegraphai/builders/graph_builder.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,10 @@ def _create_llm(self, llm_config: dict):
6565
"temperature": 0,
6666
"streaming": True
6767
}
68-
# Update defaults with any LLM parameters that were provided
6968
llm_params = {**llm_defaults, **llm_config}
7069
if "api_key" not in llm_params:
7170
raise ValueError("LLM configuration must include an 'api_key'.")
7271

73-
# select the model based on the model name
7472
if "gpt-" in llm_params["model"]:
7573
return ChatOpenAI(llm_params)
7674
elif "gemini" in llm_params["model"]:
@@ -152,17 +150,13 @@ def convert_json_to_graphviz(json_data, format: str = 'pdf'):
152150
edges = graph_config.get('edges', [])
153151
entry_point = graph_config.get('entry_point')
154152

155-
# Add nodes to the graph
156153
for node in nodes:
157-
# If this node is the entry point, use a double circle to denote it
158154
if node['node_name'] == entry_point:
159155
graph.node(node['node_name'], shape='doublecircle')
160156
else:
161157
graph.node(node['node_name'])
162158

163-
# Add edges to the graph
164159
for edge in edges:
165-
# An edge could potentially have multiple 'to' nodes if it's from a conditional node
166160
if isinstance(edge['to'], list):
167161
for to_node in edge['to']:
168162
graph.edge(edge['from'], to_node)

scrapegraphai/nodes/fetch_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def handle_web_source(self, state, source):
256256
if not self.cut:
257257
parsed_content = cleanup_html(response, source)
258258

259-
if ((isinstance(self.llm_model, ChatOpenAI) or isinstance(self.llm_model, AzureChatOpenAI))
260-
and not self.script_creator) or (self.force and not self.script_creator):
259+
if isinstance(self.llm_model, (ChatOpenAI, AzureChatOpenAI)) \
260+
and not self.script_creator) or (self.force and not self.script_creator):
261261
parsed_content = convert_to_md(source, parsed_content)
262262

263263
compressed_document = [Document(page_content=parsed_content)]

scrapegraphai/telemetry/telemetry.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
or:
1515
export SCRAPEGRAPHAI_TELEMETRY_ENABLED=false
1616
"""
17-
1817
import configparser
1918
import functools
2019
import importlib.metadata
@@ -68,14 +67,16 @@ def _check_config_and_environ_for_telemetry_flag(
6867
try:
6968
telemetry_enabled = config_obj.getboolean("DEFAULT", "telemetry_enabled")
7069
except ValueError as e:
71-
logger.debug(f"Unable to parse value for `telemetry_enabled` from config. Encountered {e}")
70+
logger.debug(f"""Unable to parse value for
71+
`telemetry_enabled` from config. Encountered {e}""")
7272
if os.environ.get("SCRAPEGRAPHAI_TELEMETRY_ENABLED") is not None:
7373
env_value = os.environ.get("SCRAPEGRAPHAI_TELEMETRY_ENABLED")
7474
config_obj["DEFAULT"]["telemetry_enabled"] = env_value
7575
try:
7676
telemetry_enabled = config_obj.getboolean("DEFAULT", "telemetry_enabled")
7777
except ValueError as e:
78-
logger.debug(f"Unable to parse value for `SCRAPEGRAPHAI_TELEMETRY_ENABLED` from environment. Encountered {e}")
78+
logger.debug(f"""Unable to parse value for `SCRAPEGRAPHAI_TELEMETRY_ENABLED`
79+
from environment. Encountered {e}""")
7980
return telemetry_enabled
8081

8182

@@ -94,15 +95,13 @@ def _check_config_and_environ_for_telemetry_flag(
9495
"telemetry_version": "0.0.3",
9596
}
9697

97-
9898
def disable_telemetry():
9999
"""
100100
function for disabling the telemetries
101101
"""
102102
global g_telemetry_enabled
103103
g_telemetry_enabled = False
104104

105-
106105
def is_telemetry_enabled() -> bool:
107106
"""
108107
function for checking if a telemetry is enables
@@ -122,7 +121,6 @@ def is_telemetry_enabled() -> bool:
122121
else:
123122
return False
124123

125-
126124
def _send_event_json(event_json: dict):
127125
headers = {
128126
"Content-Type": "application/json",
@@ -141,7 +139,6 @@ def _send_event_json(event_json: dict):
141139
else:
142140
logger.debug(f"Telemetry data sent: {data}")
143141

144-
145142
def send_event_json(event_json: dict):
146143
"""
147144
fucntion for sending event json
@@ -154,7 +151,6 @@ def send_event_json(event_json: dict):
154151
except Exception as e:
155152
logger.debug(f"Failed to send telemetry data in a thread: {e}")
156153

157-
158154
def log_event(event: str, properties: Dict[str, any]):
159155
"""
160156
function for logging the events
@@ -167,7 +163,6 @@ def log_event(event: str, properties: Dict[str, any]):
167163
}
168164
send_event_json(event_json)
169165

170-
171166
def log_graph_execution(graph_name: str, source: str, prompt:str, schema:dict,
172167
llm_model: str, embedder_model: str, source_type: str,
173168
execution_time: float, content: str = None, response: dict = None,
@@ -193,8 +188,10 @@ def log_graph_execution(graph_name: str, source: str, prompt:str, schema:dict,
193188
}
194189
log_event("graph_execution", properties)
195190

196-
197191
def capture_function_usage(call_fn: Callable) -> Callable:
192+
"""
193+
function that captures the usage
194+
"""
198195
@functools.wraps(call_fn)
199196
def wrapped_fn(*args, **kwargs):
200197
try:

scrapegraphai/utils/convert_to_md.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def convert_to_md(html: str, url: str = None) -> str:
2424
h = html2text.HTML2Text()
2525
h.ignore_links = False
2626
h.body_width = 0
27+
2728
if url is not None:
2829
parsed_url = urlparse(url)
2930
domain = f"{parsed_url.scheme}://{parsed_url.netloc}"

scrapegraphai/utils/copy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
copy module
3+
"""
14
import copy
25
from typing import Any
36

scrapegraphai/utils/save_audio_from_bytes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from pathlib import Path
55
from typing import Union
66

7-
87
def save_audio_from_bytes(byte_response: bytes, output_path: Union[str, Path]) -> None:
98
"""
109
Saves the byte response as an audio file to the specified path.

0 commit comments

Comments
 (0)