Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
refactoring of the code
VinciGit00e872f97cbff9
diff --git a/yosoai/__init__.py b/yosoai/__init__.pyindex cec705a8..d8356992 100644--- a/yosoai/__init__.py+++ b/yosoai/__init__.py@@ -2,4 +2,4 @@ from .class_creator import create_classfrom .class_generator import Generatorfrom .getter import _get_functionfrom .token_calculator import truncate_text_tokens-from .request import send_request\ No newline at end of file+from .request import send_requestdiff --git a/yosoai/class_creator.py b/yosoai/class_creator.pyindex c183d964..9cc41dc3 100644--- a/yosoai/class_creator.py+++ b/yosoai/class_creator.py@@ -18,9 +18,10 @@ from langchain_core.pydantic_v1 import BaseModel, Fieldclass _Response(BaseModel):"""-+for elem in data_dict:base_script = base_script + f" {elem['title']}: {elem['type']} = Field(description='{elem['description']}')\n"with open("./yosoai/pydantic_class.py", "w") as f:- f.write(base_script)\ No newline at end of file+ f.write(base_script)+\ No newline at end of filediff --git a/yosoai/class_generator.py b/yosoai/class_generator.pyindex 31729b37..0a37aaaf 100644--- a/yosoai/class_generator.py+++ b/yosoai/class_generator.py@@ -6,7 +6,13 @@ from langchain_core.pydantic_v1 import Fieldfrom langchain.output_parsers import PydanticOutputParserclass Generator:- def __init__(self, api_key: str, temperature_param: float = 0.0, model_name: str = "gpt-3.5-turbo") -> dict:+ def __init__(+ self,+ api_key: str,+ temperature_param: float = 0.0,+ model_name: str = "gpt-3.5-turbo"+ ) -> dict:+"""Initializes the Generator object.@@ -28,7 +34,8 @@ class Generator:partial_variables={"format_instructions": self.parser.get_format_instructions()},)- self.model = ChatOpenAI(openai_api_key=api_key, temperature=temperature_param, model=model_name)+ self.model = ChatOpenAI(openai_api_key=api_key, temperature=temperature_param,+ model=model_name)self.chain = self.prompt | self.model | self.parserdiff --git a/yosoai/dictionaries.py b/yosoai/dictionaries.pyindex 125c0f65..fb15e0af 100644--- a/yosoai/dictionaries.py+++ b/yosoai/dictionaries.py@@ -12,7 +12,7 @@ schema_example= {"project_name": {"type": "string"},"project_description": {"type": "string"},"url": {"type": "string"}- },+ },"required": ["project_name", "project_description", "url"],},},diff --git a/yosoai/remover.py b/yosoai/remover.pyindex 27e01eae..cd6515cd 100644--- a/yosoai/remover.py+++ b/yosoai/remover.py@@ -13,7 +13,7 @@ def remover(file:str, only_body:bool = False) -> str:if only_body == True:isBody = True- else:+ else:isBody = Falsefor elem in file.splitlines():@@ -32,4 +32,5 @@ def remover(file:str, only_body:bool = False) -> str:if isBody == True:res = res + elem- return res.replace("\\n", "")\ No newline at end of file+ return res.replace("\\n", "")+\ No newline at end of filediff --git a/yosoai/token_calculator.py b/yosoai/token_calculator.pyindex cb15415a..9494eba2 100644--- a/yosoai/token_calculator.py+++ b/yosoai/token_calculator.py@@ -23,4 +23,5 @@ def truncate_text_tokens(text: str, model: str, encoding_name: str) -> List[str]result = [encoding.decode(chunk) for chunk in chunks]- return result\ No newline at end of file+ return result+\ No newline at end of file