Skip to content

Ligthweigthing library #573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 23, 2024
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
13 changes: 1 addition & 12 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ markmap:

## **Short-Term Goals**

- Integration with more llm APIs

- Test proxy rotation implementation

- Add more search engines inside the SearchInternetNode

- Improve the documentation (ReadTheDocs)
- [Issue #102](https://github.com/VinciGit00/Scrapegraph-ai/issues/102)

Expand All @@ -23,9 +17,6 @@ markmap:
## **Medium-Term Goals**

- Node for handling API requests

- Improve SearchGraph to look into the first 5 results of the search engine

- Make scraping more deterministic
- Create DOM tree of the website
- HTML tag text embeddings with tags metadata
Expand Down Expand Up @@ -70,6 +61,4 @@ markmap:

- Automatic generation of scraping pipelines from a given prompt

- Create API for the library

- Finetune a LLM for html content
- Create API for the library
38 changes: 22 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
[project]
name = "scrapegraphai"


version = "1.14.1b1"


description = "A web scraping library based on LangChain which uses LLM and direct graph logic to create scraping pipelines."

authors = [
{ name = "Marco Vinciguerra", email = "mvincig11@gmail.com" },
{ name = "Marco Perini", email = "perinim.98@gmail.com" },
Expand All @@ -15,32 +10,24 @@ authors = [

dependencies = [
"langchain>=0.2.14",
"langchain-fireworks>=0.1.3",
"langchain_community>=0.2.9",
"langchain-google-genai>=1.0.7",
"langchain-google-vertexai>=1.0.7",
"langchain-openai>=0.1.22",
"langchain-groq>=0.1.3",
"langchain-aws>=0.1.3",
"langchain-anthropic>=0.1.11",
"langchain-mistralai>=0.1.12",
"langchain-huggingface>=0.0.3",
"langchain-nvidia-ai-endpoints>=0.1.6",
"langchain_community>=0.2.9",
"langchain-aws>=0.1.3",
"html2text>=2024.2.26",
"faiss-cpu>=1.8.0",
"beautifulsoup4>=4.12.3",
"pandas>=2.2.2",
"python-dotenv>=1.0.1",
"tiktoken>=0.7",
"tqdm>=4.66.4",
"graphviz>=0.20.3",
"minify-html>=0.15.0",
"free-proxy>=1.1.1",
"playwright>=1.43.0",
"google>=3.0.0",
"undetected-playwright>=0.3.0",
"google>=3.0.0",
"semchunk>=1.0.1",
"browserbase>=0.3.0",
]

license = "MIT"
Expand Down Expand Up @@ -79,6 +66,25 @@ requires-python = ">=3.9,<4.0"
burr = ["burr[start]==0.22.1"]
docs = ["sphinx==6.0", "furo==2024.5.6"]

# Group 1: Other Language Models
other-language-models = [
"langchain-fireworks>=0.1.3",
"langchain-groq>=0.1.3",
"langchain-anthropic>=0.1.11",
"langchain-huggingface>=0.0.3",
"langchain-nvidia-ai-endpoints>=0.1.6",
]

# Group 2: More Semantic Options
more-semantic-options = [
"graphviz>=0.20.3",
]

# Group 3: More Browser Options
more-browser-options = [
"browserbase>=0.3.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Expand Down
10 changes: 6 additions & 4 deletions scrapegraphai/graphs/abstract_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,18 @@ def handle_model(model_name, provider, token_key, default_token=8192):
warnings.simplefilter("ignore")
return init_chat_model(**llm_params)

known_models = {"chatgpt","gpt","openai", "azure_openai", "google_genai", "ollama", "oneapi", "nvidia", "groq", "google_vertexai", "bedrock", "mistralai", "hugging_face", "deepseek", "ernie", "fireworks"}
known_models = ["chatgpt","gpt","openai", "azure_openai", "google_genai",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

known_models = {...}, not square brackets

"ollama", "oneapi", "nvidia", "groq", "google_vertexai",
"bedrock", "mistralai", "hugging_face", "deepseek", "ernie", "fireworks"]


if llm_params["model"].split("/")[0] not in known_models and llm_params["model"].split("-")[0] not in known_models:
raise ValueError(f"Model '{llm_params['model']}' is not supported")

try:
if "azure" in llm_params["model"]:
model_name = llm_params["model"].split("/")[-1]
return handle_model(model_name, "azure_openai", model_name)

return handle_model(model_name, "azure_openai", model_name)
if "fireworks" in llm_params["model"]:
model_name = "/".join(llm_params["model"].split("/")[1:])
token_key = llm_params["model"].split("/")[-1]
Expand Down Expand Up @@ -185,7 +188,6 @@ def handle_model(model_name, provider, token_key, default_token=8192):
model_name = llm_params["model"].split("/")[-1]
return handle_model(model_name, "mistralai", model_name)

# Instantiate the language model based on the model name (models that do not use the common interface)
elif "deepseek" in llm_params["model"]:
try:
self.model_token = models_tokens["deepseek"][llm_params["model"]]
Expand Down
3 changes: 2 additions & 1 deletion scrapegraphai/nodes/fetch_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from langchain_core.documents import Document
from ..utils.cleanup_html import cleanup_html
from ..docloaders import ChromiumLoader
from ..docloaders.browser_base import browser_base_fetch
from ..utils.convert_to_md import convert_to_md
from ..utils.logging import get_logger
from .base_node import BaseNode
Expand Down Expand Up @@ -269,6 +268,8 @@ def handle_web_source(self, state, source):
loader_kwargs = self.node_config.get("loader_kwargs", {})

if self.browser_base is not None:
from ..docloaders.browser_base import browser_base_fetch

data = browser_base_fetch(self.browser_base.get("api_key"),
self.browser_base.get("project_id"), [source])

Expand Down
Loading