Skip to content

Commit ebdb749

Browse files
committed
add new model for gpt
1 parent 391d051 commit ebdb749

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

examples/openai/smart_scraper_schema_openai.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os, json
66
from typing import List
77
from dotenv import load_dotenv
8-
from pydantic import BaseModel, Field
8+
from langchain_core.pydantic_v1 import BaseModel, Field
99
from scrapegraphai.graphs import SmartScraperGraph
1010

1111
load_dotenv()
@@ -30,7 +30,7 @@ class Projects(BaseModel):
3030
graph_config = {
3131
"llm": {
3232
"api_key":openai_key,
33-
"model": "chatgpt-4o-latest",
33+
"model": "gpt-4o-mini",
3434
},
3535
"verbose": True,
3636
"headless": False,

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ authors = [
1414
]
1515

1616
dependencies = [
17-
"langchain>=0.2.10",
17+
"langchain==0.2.14",
1818
"langchain-fireworks>=0.1.3",
1919
"langchain_community>=0.2.9",
2020
"langchain-google-genai>=1.0.7",
2121
"langchain-google-vertexai>=1.0.7",
22-
"langchain-openai>=0.1.17",
22+
"langchain-openai==0.1.22",
2323
"langchain-groq>=0.1.3",
2424
"langchain-aws>=0.1.3",
2525
"langchain-anthropic>=0.1.11",

requirements-dev.lock

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ graphviz==0.20.3
179179
# via scrapegraphai
180180
greenlet==3.0.3
181181
# via playwright
182-
# via sqlalchemy
183182
groq==0.9.0
184183
# via langchain-groq
185184
grpc-google-iam-v1==0.13.1
@@ -255,7 +254,7 @@ jsonschema-specifications==2023.12.1
255254
# via jsonschema
256255
kiwisolver==1.4.5
257256
# via matplotlib
258-
langchain==0.2.12
257+
langchain==0.2.14
259258
# via langchain-community
260259
# via scrapegraphai
261260
langchain-anthropic==0.1.22
@@ -264,7 +263,7 @@ langchain-aws==0.1.16
264263
# via scrapegraphai
265264
langchain-community==0.2.11
266265
# via scrapegraphai
267-
langchain-core==0.2.29
266+
langchain-core==0.2.33
268267
# via langchain
269268
# via langchain-anthropic
270269
# via langchain-aws
@@ -292,7 +291,7 @@ langchain-mistralai==0.1.12
292291
# via scrapegraphai
293292
langchain-nvidia-ai-endpoints==0.2.1
294293
# via scrapegraphai
295-
langchain-openai==0.1.21
294+
langchain-openai==0.1.22
296295
# via scrapegraphai
297296
langchain-text-splitters==0.2.2
298297
# via langchain

requirements.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ graphviz==0.20.3
133133
# via scrapegraphai
134134
greenlet==3.0.3
135135
# via playwright
136-
# via sqlalchemy
137136
groq==0.9.0
138137
# via langchain-groq
139138
grpc-google-iam-v1==0.13.1
@@ -178,6 +177,7 @@ jinja2==3.1.4
178177
# via torch
179178
jiter==0.5.0
180179
# via anthropic
180+
# via openai
181181
jmespath==1.0.1
182182
# via boto3
183183
# via botocore
@@ -187,7 +187,7 @@ jsonpatch==1.33
187187
# via langchain-core
188188
jsonpointer==3.0.0
189189
# via jsonpatch
190-
langchain==0.2.11
190+
langchain==0.2.14
191191
# via langchain-community
192192
# via scrapegraphai
193193
langchain-anthropic==0.1.20
@@ -196,7 +196,7 @@ langchain-aws==0.1.12
196196
# via scrapegraphai
197197
langchain-community==0.2.10
198198
# via scrapegraphai
199-
langchain-core==0.2.28
199+
langchain-core==0.2.33
200200
# via langchain
201201
# via langchain-anthropic
202202
# via langchain-aws
@@ -224,7 +224,7 @@ langchain-mistralai==0.1.12
224224
# via scrapegraphai
225225
langchain-nvidia-ai-endpoints==0.1.7
226226
# via scrapegraphai
227-
langchain-openai==0.1.17
227+
langchain-openai==0.1.22
228228
# via scrapegraphai
229229
langchain-text-splitters==0.2.2
230230
# via langchain
@@ -264,7 +264,7 @@ numpy==1.26.4
264264
# via sentence-transformers
265265
# via shapely
266266
# via transformers
267-
openai==1.37.0
267+
openai==1.41.0
268268
# via langchain-fireworks
269269
# via langchain-openai
270270
orjson==3.10.6

scrapegraphai/nodes/generate_answer_node.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ def execute(self, state: dict) -> dict:
8888
# Initialize the output parser
8989
if self.node_config.get("schema", None) is not None:
9090
output_parser = JsonOutputParser(pydantic_object=self.node_config["schema"])
91-
if isinstance(self.llm_model, ChatOpenAI):
92-
self.llm_model = self.llm_model.with_structured_output(self.node_config["schema"], method="json_mode")
91+
if isinstance(self.llm_model, ChatOpenAI) and (self.llm_model.model_name=="gpt-4o-mini" or self.llm_model.model_name=="gpt-4o-2024-08-06"):
92+
self.llm_model = self.llm_model.with_structured_output(
93+
schema = self.node_config["schema"],
94+
method="json_schema")
9395

9496
else:
9597
output_parser = JsonOutputParser()

0 commit comments

Comments
 (0)