Skip to content

Commit 72873c1

Browse files
committed
refactoring of teh code
1 parent 7fea150 commit 72873c1

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

examples/openai/smart_scraper_schema_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Projects(BaseModel):
2929

3030
graph_config = {
3131
"llm": {
32-
"api_key":openai_key,
32+
"api_key": openai_key,
3333
"model": "openai/gpt-4o-mini",
3434
},
3535
"verbose": True,

scrapegraphai/nodes/generate_answer_node.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,16 @@ def execute(self, state: dict) -> dict:
8282

8383
self.logger.info(f"--- Executing {self.node_name} Node ---")
8484

85-
input_keys = self.get_input_keys(state)
86-
85+
input_keys = self.get_input_keys(state)
8786
input_data = [state[key] for key in input_keys]
8887
user_prompt = input_data[0]
8988
doc = input_data[1]
9089

9190
if self.node_config.get("schema", None) is not None:
92-
91+
9392
if isinstance(self.llm_model, (ChatOpenAI, ChatMistralAI)):
9493
self.llm_model = self.llm_model.with_structured_output(
95-
schema = self.node_config["schema"]) # json schema works only on specific models
96-
94+
schema = self.node_config["schema"])
9795
output_parser = get_structured_output_parser(self.node_config["schema"])
9896
format_instructions = "NA"
9997
else:
@@ -120,7 +118,7 @@ def execute(self, state: dict) -> dict:
120118
if self.additional_info is not None:
121119
template_no_chunks_prompt = self.additional_info + template_no_chunks_prompt
122120
template_chunks_prompt = self.additional_info + template_chunks_prompt
123-
template_merge_prompt = self.additional_info + template_merge_prompt
121+
template_merge_prompt = self.additional_info + template_merge_prompt
124122

125123
if len(doc) == 1:
126124
prompt = PromptTemplate(

0 commit comments

Comments
 (0)