MCPcopy Create free account
hub / github.com/Hello-SimpleAI/chatgpt-comparison-detection / process_data

Function process_data

HC3/selenium_crawler.py:371–392  ·  view source on GitHub ↗
(
    questions: Dict[int, Dict], prefix: str = 'data/', num_answers: int = 1
)

Source from the content-addressed store, hash-verified

369
370
371def process_data(
372 questions: Dict[int, Dict], prefix: str = 'data/', num_answers: int = 1
373) -> List[List[str]]:
374 time.sleep(1)
375 for i, q in questions.items():
376 timer = time.time()
377 try:
378 answers = chatgpt(q['query'], num_answers)
379 except WillBeSkipped:
380 time.sleep(random.uniform(1, 5))
381 new_chat()
382 continue
383 q['chats'] = answers
384 with open(f'{prefix}.{i}.json', mode='w', encoding='utf8') as file:
385 # q.pop('query')
386 json.dump(q, file, indent=2, ensure_ascii=False)
387 printf(f'Saved at', file.name)
388 time.sleep(random.uniform(1, 5))
389 new_chat()
390 timer = time.time() - timer
391 # if timer < 45:
392 # time.sleep(45 - timer)
393
394
395def read_data(filename: str) -> Dict[int, Dict]:

Callers 1

mainFunction · 0.85

Calls 3

chatgptFunction · 0.85
new_chatFunction · 0.85
printfFunction · 0.70

Tested by

no test coverage detected