This commit is contained in:
严浩
2025-01-13 17:21:40 +08:00
parent 456f56e40d
commit 320df7e2a5
5 changed files with 186 additions and 0 deletions

28
app-ollama.py Normal file
View File

@ -0,0 +1,28 @@
from scrapegraphai.graphs import SmartScraperGraph
graph_config = {
"llm": {
# "model": "ollama/mistral-nemo:latest",
"model": "ollama/mistral:latest",
"temperature": 0, # 更准确执行任务
"format": "json", # Ollama 需要显式指定格式
},
"embeddings": {
"model": "ollama/nomic-embed-text",
},
"verbose": True,
# "headless": False,
}
# 抓取网页标题
smart_scraper_graph = SmartScraperGraph(
prompt="List all article titles on the page",
# prompt="列出页面上的所有文章标题",
source="https://www.aivi.fyi/",
config=graph_config
)
# Run the pipeline
result = smart_scraper_graph.run()
print(result)