Scrapegraph-ai/examples/fireworks/json_scraper_multi_fireworks.py
Marco Vinciguerra 4b56604413
Some checks failed
/ build (3.10) (push) Has been cancelled
add examples + test
2024-06-25 10:32:29 +02:00

45 lines
1.1 KiB
Python

"""
Module for showing how PDFScraper multi works
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperMultiGraph
load_dotenv()
fireworks_api_key = os.getenv("FIREWORKS_APIKEY")
graph_config = {
"llm": {
"api_key": fireworks_api_key,
"model": "fireworks/accounts/fireworks/models/mixtral-8x7b-instruct"
},
"embeddings": {
"model": "ollama/nomic-embed-text",
"temperature": 0,
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
},
"verbose": True,
"headless": False,
}
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))