Skip to content

Python scraper based on AI

fix: remover bug

PeriniMeacda97a1c34
diff --git a/.gitignore b/.gitignore
index 7a9e89dc..45159e0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@ docs/source/_templates/
docs/source/_static/
.env
venv/
+.vscode/
diff --git a/examples/html_scraping.py b/examples/html_scraping.py
index c19ba9cb..d9d75c64 100644
--- a/examples/html_scraping.py
+++ b/examples/html_scraping.py
@@ -1,6 +1,6 @@
import os
from dotenv import load_dotenv
-from yosoai.request import send_request
+from yosoai import send_request
load_dotenv()
diff --git a/examples/value_scraping.py b/examples/value_scraping.py
index 6c55cb84..041ead84 100644
--- a/examples/value_scraping.py
+++ b/examples/value_scraping.py
@@ -1,7 +1,6 @@
import os
from dotenv import load_dotenv
-from yosoai.getter import get_function
-from yosoai.request import send_request
+from yosoai import get_function, send_request
load_dotenv()
diff --git a/pydantic_class.py b/pydantic_class.py
index 87f2c56d..6a6d72a1 100644
--- a/pydantic_class.py
+++ b/pydantic_class.py
@@ -2,4 +2,4 @@
from langchain_core.pydantic_v1 import BaseModel, Field
class _Response(BaseModel):
- title: str = Field(description='Title of the news')
+ title_news: str = Field(description='Give me the name of the news')
diff --git a/yosoai/__init__.py b/yosoai/__init__.py
index fc00b1fe..e7c7a79f 100644
--- a/yosoai/__init__.py
+++ b/yosoai/__init__.py
@@ -1,4 +1,5 @@
from .class_creator import create_class
from .class_generator import Generator
-from .pydantic_class import _Response
-from .getter import remover
\ No newline at end of file
+from .getter import remover, get_function
+from .token_calculator import truncate_text_tokens
+from .request import send_request
\ No newline at end of file
diff --git a/yosoai/getter.py b/yosoai/getter.py
index a90632cd..a5a38325 100644
--- a/yosoai/getter.py
+++ b/yosoai/getter.py
@@ -17,7 +17,7 @@ def get_function(link:str, param = HEADERS) -> str:
response = requests.get(url=link, headers=param)
return str(response.content)
-def remover(file:str) -> str:
+def remover(file:str, only_body:bool = False) -> str:
"""
This function elaborates the HTML file and remove all the not necessary tag
@@ -30,7 +30,10 @@ def remover(file:str) -> str:
res = ""
- isBody = False
+ if only_body == True:
+ isBody = True
+ else:
+ isBody = False
for elem in file.splitlines():
if "<title>" in elem:
diff --git a/yosoai/request.py b/yosoai/request.py
index 7333d405..54ce9c45 100644
--- a/yosoai/request.py
+++ b/yosoai/request.py
@@ -32,7 +32,7 @@ def send_request(key: str, text:str, values:list[dict], model:str, temperature:f
create_class(values)
time.sleep(2) # TODO: implement an asynchrous waiting
- text = remover(text)
+ # text = remover(text)
messages = truncate_text_tokens(text, model, encoding_name)