Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ authors = [

dependencies = [
"langchain>=1.2.0",
"langchain-classic>=1.0.0",
"langchain-openai>=1.1.6",
"langchain-mistralai>=1.1.1",
"langchain_community>=0.3.31",
Expand All @@ -26,7 +27,7 @@ dependencies = [
"playwright>=1.57.0",
"undetected-playwright>=0.3.0",
"semchunk>=3.2.5",
"async-timeout>=5.0.1",
"async-timeout>=4.0.0",
"simpleeval>=1.0.3",
"jsonschema>=4.25.1",
"duckduckgo-search>=8.1.1",
Expand Down
6 changes: 4 additions & 2 deletions scrapegraphai/builders/graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
GraphBuilder Module
"""

from langchain.chains import create_extraction_chain
from langchain_classic.chains import create_extraction_chain
from langchain_community.chat_models import ErnieBotChat
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -113,7 +113,9 @@ def _create_extraction_chain(self):
{nodes_description}

Based on the user's input: "{input}", identify the essential nodes required for the task and suggest a graph configuration that outlines the flow between the chosen nodes.
""".format(nodes_description=self.nodes_description, input="{input}")
""".format(
nodes_description=self.nodes_description, input="{input}"
)
extraction_prompt = ChatPromptTemplate.from_template(
create_graph_prompt_template
)
Expand Down
8 changes: 4 additions & 4 deletions scrapegraphai/nodes/generate_answer_node_k_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from typing import List, Optional

from langchain_core.prompts import PromptTemplate
from langchain_aws import ChatBedrock
from langchain_community.chat_models import ChatOllama
from langchain_core.output_parsers import JsonOutputParser
from langchain_core.prompts import PromptTemplate
from langchain_core.runnables import RunnableParallel
from langchain_mistralai import ChatMistralAI
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -151,7 +151,7 @@ def execute(self, state: dict) -> dict:
template=template_chunks_prompt,
input_variables=["format_instructions"],
partial_variables={
"context": chunk.get("document"),
"content": chunk.get("document"),
"chunk_id": i + 1,
},
)
Expand All @@ -163,14 +163,14 @@ def execute(self, state: dict) -> dict:

merge_prompt = PromptTemplate(
template=template_merge_prompt,
input_variables=["context", "question"],
input_variables=["content", "question"],
partial_variables={"format_instructions": format_instructions},
)

merge_chain = merge_prompt | self.llm_model
if output_parser:
merge_chain = merge_chain | output_parser
answer = merge_chain.invoke({"context": batch_results, "question": user_prompt})
answer = merge_chain.invoke({"content": batch_results, "question": user_prompt})

state["answer"] = answer

Expand Down
4 changes: 2 additions & 2 deletions scrapegraphai/nodes/generate_code_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from bs4 import BeautifulSoup
from jsonschema import ValidationError as JSONSchemaValidationError
from jsonschema import validate
from langchain_core.output_parsers import ResponseSchema, StructuredOutputParser
from langchain_core.prompts import PromptTemplate
from langchain_classic.output_parsers import ResponseSchema, StructuredOutputParser
from langchain_community.chat_models import ChatOllama
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import PromptTemplate

from ..prompts import TEMPLATE_INIT_CODE_GENERATION, TEMPLATE_SEMANTIC_COMPARISON
from ..utils import (
Expand Down