Skip to content

Python scraper based on AI

Merge branch 'multiple-requests' into get_request_new

VinciGit00ec6b284dfae6
diff --cc yosoai/request.py
index 2a1fa20b,4afc89b3..ef34da4e
--- a/yosoai/request.py
+++ b/yosoai/request.py
@@@ -1,6 -1,7 +1,8 @@@
import time
+from tqdm import tqdm
from typing import List
+ from multiprocessing import Pool
+ from tqdm import tqdm # Import tqdm for progress bar
from .getter import remover
from .class_generator import Generator
from .class_creator import create_class
@@@ -8,13 -9,15 +10,12 @@@ from .token_calculator import truncate_
EMBEDDING_ENCODING = 'cl100k_base'
-def process_message(args):
- key, temperature, model, encoding_name, message = args
- generator_instance = Generator(key, temperature, model)
- result = generator_instance.invocation(message)
- return result
+LAST_REQUEST_TIME = 0
+REQUEST_INTERVAL = 20 # Adjust as needed, represents the interval in seconds between requests
-def send_request(key: str, text: str, values: list[dict], model: str, temperature: float = 0.0, encoding_name: str = EMBEDDING_ENCODING) -> List[dict]:
+def send_request(key: str, text:str, values:list[dict], model:str, temperature:float = 0.0, encoding_name: str = EMBEDDING_ENCODING) -> List[dict]:
"""
Send a request to openai.
-
Args:
key (str): The API key for accessing the language model.
text (str): The input text to be processed.