mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-07-04 21:00:36 +08:00
This commit is contained in:
parent
786af992f8
commit
b0ffc51e54
@ -5,8 +5,7 @@ Example of custom graph using existing nodes
|
|||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from langchain_openai import OpenAIEmbeddings
|
from langchain_mistralai import ChatMistralAI, MistralAIEmbeddings
|
||||||
from scrapegraphai.models import OpenAI
|
|
||||||
from scrapegraphai.graphs import BaseGraph
|
from scrapegraphai.graphs import BaseGraph
|
||||||
from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
|
from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
@ -27,8 +26,8 @@ graph_config = {
|
|||||||
# Define the graph nodes
|
# Define the graph nodes
|
||||||
# ************************************************
|
# ************************************************
|
||||||
|
|
||||||
llm_model = OpenAI(graph_config["llm"])
|
llm_model = ChatMistralAI(**graph_config["llm"])
|
||||||
embedder = OpenAIEmbeddings(api_key=llm_model.openai_api_key)
|
embedder = MistralAIEmbeddings(api_key=llm_model.mistral_api_key)
|
||||||
|
|
||||||
# define the nodes for the graph
|
# define the nodes for the graph
|
||||||
robot_node = RobotsNode(
|
robot_node = RobotsNode(
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
"""
|
|
||||||
Basic example of scraping pipeline using SpeechSummaryGraph
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
from scrapegraphai.graphs import SpeechGraph
|
|
||||||
from scrapegraphai.utils import prettify_exec_info
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
# ************************************************
|
|
||||||
# Define audio output path
|
|
||||||
# ************************************************
|
|
||||||
|
|
||||||
FILE_NAME = "website_summary.mp3"
|
|
||||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
output_path = os.path.join(curr_dir, FILE_NAME)
|
|
||||||
|
|
||||||
# ************************************************
|
|
||||||
# Define the configuration for the graph
|
|
||||||
# ************************************************
|
|
||||||
|
|
||||||
mistral_key = os.getenv("MISTRAL_API_KEY")
|
|
||||||
|
|
||||||
graph_config = {
|
|
||||||
"llm": {
|
|
||||||
"api_key": mistral_key,
|
|
||||||
"model": "mistral/open-mistral-nemo",
|
|
||||||
"temperature": 0.7,
|
|
||||||
},
|
|
||||||
"tts_model": {
|
|
||||||
"api_key": mistral_key,
|
|
||||||
"model": "tts-1",
|
|
||||||
"voice": "alloy"
|
|
||||||
},
|
|
||||||
"output_path": output_path,
|
|
||||||
}
|
|
||||||
|
|
||||||
# ************************************************
|
|
||||||
# Create the SpeechGraph instance and run it
|
|
||||||
# ************************************************
|
|
||||||
|
|
||||||
speech_graph = SpeechGraph(
|
|
||||||
prompt="Make a detailed audio summary of the projects.",
|
|
||||||
source="https://perinim.github.io/projects/",
|
|
||||||
config=graph_config,
|
|
||||||
)
|
|
||||||
|
|
||||||
result = speech_graph.run()
|
|
||||||
print(result)
|
|
||||||
|
|
||||||
# ************************************************
|
|
||||||
# Get graph execution info
|
|
||||||
# ************************************************
|
|
||||||
|
|
||||||
graph_exec_info = speech_graph.get_execution_info()
|
|
||||||
print(prettify_exec_info(graph_exec_info))
|
|
||||||
Loading…
Reference in New Issue
Block a user