Skip to content

Python scraper based on AI

docs: update instructions to use with LocalAI

Ettore Di Giacinto198420c50554
diff --git a/README.md b/README.md
index 719ecd50..47e3beb7 100644
--- a/README.md
+++ b/README.md
@@ -239,6 +239,36 @@ The output for all 3 the cases will be a dictionary with the extracted informati
}
```
+### Case 7: Extract informations with LocalAI
+
+For LocalAI, the OpenAI client can be used by specifing a "fake" `OPENAI_API_KEY` ( there is no need to specify a real OpenAI key ):
+
+```python
+from scrapegraphai.graphs import SmartScraperGraph
+
+# Note: You can actually leave as-is
+OPENAI_API_KEY = "YOUR_API_KEY"
+
+graph_config = {
+ "llm": {
+ "api_key": OPENAI_API_KEY,
+ "model": "gpt-4",
+ "temperature": 0,
+ "base_url": "http://localhost:8080",
+ },
+}
+
+smart_scraper_graph = SmartScraperGraph(
+ prompt="List me all the articles",
+ # also accepts a string with the already downloaded HTML code
+ source="https://perinim.github.io/projects",
+ config=graph_config
+)
+
+result = smart_scraper_graph.run()
+print(result)
+```
+
## 🤝 Contributing
Feel free to contribute and join our Discord server to discuss with us improvements and give us suggestions!