Scrapegraph-ai/examples/oneapi/json_scraper_multi_oneapi.py
Marco Vinciguerra dd2b3a8f59
Some checks failed
/ build (3.10) (push) Has been cancelled
Release / Build (push) Has been cancelled
Release / Release (push) Has been cancelled
add examples
2024-06-05 21:08:00 +02:00

33 lines
819 B
Python

"""
Module for showing how PDFScraper multi works
"""
import os
import json
from scrapegraphai.graphs import JSONScraperMultiGraph
graph_config = {
"llm": {
"api_key": "***************************",
"model": "oneapi/qwen-turbo",
"base_url": "http://127.0.0.1:3000/v1", # 设置 OneAPI URL
}
}
FILE_NAME = "inputs/example.json"
curr_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(curr_dir, FILE_NAME)
with open(file_path, 'r', encoding="utf-8") as file:
text = file.read()
sources = [text, text]
multiple_search_graph = JSONScraperMultiGraph(
prompt= "List me all the authors, title and genres of the books",
source= sources,
schema=None,
config=graph_config
)
result = multiple_search_graph.run()
print(json.dumps(result, indent=4))