From 198420c505544c88805e719e2fc864f061c7de05 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Fri, 10 May 2024 14:17:53 +0200 Subject: [PATCH] docs: update instructions to use with LocalAI --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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!