Skip to content

Python scraper based on AI

removed dict info and put in another file

VinciGit007390dba0abe5
diff --git a/scrapegraphai/helpers/__init__.py b/scrapegraphai/helpers/__init__.py
index daf2d09e..4ca7bd2b 100644
--- a/scrapegraphai/helpers/__init__.py
+++ b/scrapegraphai/helpers/__init__.py
@@ -4,3 +4,4 @@ __init__.py for th e helpers folder
"""
from .nodes_metadata import nodes_metadata
from .schemas import graph_schema
+from .models_tokens import models_tokens
diff --git a/scrapegraphai/helpers/models_tokens.py b/scrapegraphai/helpers/models_tokens.py
new file mode 100644
index 00000000..abdfc4b0
--- /dev/null
+++ b/scrapegraphai/helpers/models_tokens.py
@@ -0,0 +1,17 @@
+"""
+Models token
+"""
+models_tokens = {
+ "gpt-3.5-turbo-0125": 16385,
+ "gpt-3.5-turbo": 4096,
+ "gpt-3.5-turbo-1106": 16385,
+ "gpt-3.5-turbo-instruct": 4096,
+ "gpt-4-0125-preview": 128000,
+ "gpt-4-turbo-preview": 128000,
+ "gpt-4-1106-preview": 128000,
+ "gpt-4-vision-preview": 128000,
+ "gpt-4": 8192,
+ "gpt-4-0613": 8192,
+ "gpt-4-32k": 32768,
+ "gpt-4-32k-0613": 32768,
+}
diff --git a/scrapegraphai/utils/token_calculator.py b/scrapegraphai/utils/token_calculator.py
index b3b0a6ed..5b46a1b8 100644
--- a/scrapegraphai/utils/token_calculator.py
+++ b/scrapegraphai/utils/token_calculator.py
@@ -3,21 +3,8 @@ Module for truncatinh in chunks the messages
"""
from typing import List
import tiktoken
+from ..helpers.models_tokens import models_tokens
-models_tokens = {
- "gpt-3.5-turbo-0125": 16385,
- "gpt-3.5-turbo": 4096,
- "gpt-3.5-turbo-1106": 16385,
- "gpt-3.5-turbo-instruct": 4096,
- "gpt-4-0125-preview": 128000,
- "gpt-4-turbo-preview": 128000,
- "gpt-4-1106-preview": 128000,
- "gpt-4-vision-preview": 128000,
- "gpt-4": 8192,
- "gpt-4-0613": 8192,
- "gpt-4-32k": 32768,
- "gpt-4-32k-0613": 32768,
-}
def truncate_text_tokens(text: str, model: str, encoding_name: str) -> List[str]:
"""