Skip to content

Commit 198420c

Browse files
authored
docs: update instructions to use with LocalAI
1 parent 702e913 commit 198420c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,36 @@ The output for all 3 the cases will be a dictionary with the extracted informati
239239
}
240240
```
241241

242+
### Case 7: Extract informations with LocalAI
243+
244+
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 ):
245+
246+
```python
247+
from scrapegraphai.graphs import SmartScraperGraph
248+
249+
# Note: You can actually leave as-is
250+
OPENAI_API_KEY = "YOUR_API_KEY"
251+
252+
graph_config = {
253+
"llm": {
254+
"api_key": OPENAI_API_KEY,
255+
"model": "gpt-4",
256+
"temperature": 0,
257+
"base_url": "http://localhost:8080",
258+
},
259+
}
260+
261+
smart_scraper_graph = SmartScraperGraph(
262+
prompt="List me all the articles",
263+
# also accepts a string with the already downloaded HTML code
264+
source="https://perinim.github.io/projects",
265+
config=graph_config
266+
)
267+
268+
result = smart_scraper_graph.run()
269+
print(result)
270+
```
271+
242272
## 🤝 Contributing
243273

244274
Feel free to contribute and join our Discord server to discuss with us improvements and give us suggestions!

0 commit comments

Comments
 (0)