docs: update instructions to use with LocalAI

This commit is contained in:
Ettore Di Giacinto 2024-05-10 14:17:53 +02:00 committed by GitHub
parent 702e913193
commit 198420c505
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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!