Merge branch 'main' into delete_doc
Browse files- README.md +108 -34
- lightrag/llm/ollama.py +2 -2
README.md
CHANGED
@@ -192,7 +192,7 @@ async def main():
|
|
192 |
rag.insert("Your text")
|
193 |
|
194 |
# Perform hybrid search
|
195 |
-
mode="hybrid"
|
196 |
print(
|
197 |
await rag.query(
|
198 |
"What are the top themes in this story?",
|
@@ -1254,6 +1254,33 @@ Valid modes are:
|
|
1254 |
|
1255 |
</details>
|
1256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1257 |
## LightRAG API
|
1258 |
|
1259 |
The LightRAG Server is designed to provide Web UI and API support. **For more information about LightRAG Server, please refer to [LightRAG Server](./lightrag/api/README.md).**
|
@@ -1519,7 +1546,47 @@ def extract_queries(file_path):
|
|
1519 |
|
1520 |
</details>
|
1521 |
|
1522 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1523 |
|
1524 |
<a href="https://star-history.com/#HKUDS/LightRAG&Date">
|
1525 |
<picture>
|
@@ -1529,42 +1596,22 @@ def extract_queries(file_path):
|
|
1529 |
</picture>
|
1530 |
</a>
|
1531 |
|
1532 |
-
## Contribution
|
1533 |
-
|
1534 |
-
Thank you to all our contributors!
|
1535 |
|
1536 |
-
<
|
1537 |
-
|
1538 |
-
</
|
1539 |
-
|
1540 |
-
## Troubleshooting
|
1541 |
-
|
1542 |
-
### Common Initialization Errors
|
1543 |
-
|
1544 |
-
If you encounter these errors when using LightRAG:
|
1545 |
-
|
1546 |
-
1. **`AttributeError: __aenter__`**
|
1547 |
-
- **Cause**: Storage backends not initialized
|
1548 |
-
- **Solution**: Call `await rag.initialize_storages()` after creating the LightRAG instance
|
1549 |
-
|
1550 |
-
2. **`KeyError: 'history_messages'`**
|
1551 |
-
- **Cause**: Pipeline status not initialized
|
1552 |
-
- **Solution**: Call `await initialize_pipeline_status()` after initializing storages
|
1553 |
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
await rag.initialize_storages()
|
1560 |
-
await initialize_pipeline_status()
|
1561 |
-
```
|
1562 |
|
1563 |
-
|
1564 |
|
1565 |
-
When switching between different embedding models, you must clear the data directory to avoid errors. The only file you may want to preserve is `kv_store_llm_response_cache.json` if you wish to retain the LLM cache.
|
1566 |
|
1567 |
-
##
|
1568 |
|
1569 |
```python
|
1570 |
@article{guo2024lightrag,
|
@@ -1577,4 +1624,31 @@ primaryClass={cs.IR}
|
|
1577 |
}
|
1578 |
```
|
1579 |
|
1580 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
rag.insert("Your text")
|
193 |
|
194 |
# Perform hybrid search
|
195 |
+
mode = "hybrid"
|
196 |
print(
|
197 |
await rag.query(
|
198 |
"What are the top themes in this story?",
|
|
|
1254 |
|
1255 |
</details>
|
1256 |
|
1257 |
+
## Troubleshooting
|
1258 |
+
|
1259 |
+
### Common Initialization Errors
|
1260 |
+
|
1261 |
+
If you encounter these errors when using LightRAG:
|
1262 |
+
|
1263 |
+
1. **`AttributeError: __aenter__`**
|
1264 |
+
- **Cause**: Storage backends not initialized
|
1265 |
+
- **Solution**: Call `await rag.initialize_storages()` after creating the LightRAG instance
|
1266 |
+
|
1267 |
+
2. **`KeyError: 'history_messages'`**
|
1268 |
+
- **Cause**: Pipeline status not initialized
|
1269 |
+
- **Solution**: Call `await initialize_pipeline_status()` after initializing storages
|
1270 |
+
|
1271 |
+
3. **Both errors in sequence**
|
1272 |
+
- **Cause**: Neither initialization method was called
|
1273 |
+
- **Solution**: Always follow this pattern:
|
1274 |
+
```python
|
1275 |
+
rag = LightRAG(...)
|
1276 |
+
await rag.initialize_storages()
|
1277 |
+
await initialize_pipeline_status()
|
1278 |
+
```
|
1279 |
+
|
1280 |
+
### Model Switching Issues
|
1281 |
+
|
1282 |
+
When switching between different embedding models, you must clear the data directory to avoid errors. The only file you may want to preserve is `kv_store_llm_response_cache.json` if you wish to retain the LLM cache.
|
1283 |
+
|
1284 |
## LightRAG API
|
1285 |
|
1286 |
The LightRAG Server is designed to provide Web UI and API support. **For more information about LightRAG Server, please refer to [LightRAG Server](./lightrag/api/README.md).**
|
|
|
1546 |
|
1547 |
</details>
|
1548 |
|
1549 |
+
## π Related Projects
|
1550 |
+
|
1551 |
+
*Ecosystem & Extensions*
|
1552 |
+
|
1553 |
+
<div align="center">
|
1554 |
+
<table>
|
1555 |
+
<tr>
|
1556 |
+
<td align="center">
|
1557 |
+
<a href="https://github.com/HKUDS/RAG-Anything">
|
1558 |
+
<div style="width: 100px; height: 100px; background: linear-gradient(135deg, rgba(0, 217, 255, 0.1) 0%, rgba(0, 217, 255, 0.05) 100%); border-radius: 15px; border: 1px solid rgba(0, 217, 255, 0.2); display: flex; align-items: center; justify-content: center; margin-bottom: 10px;">
|
1559 |
+
<span style="font-size: 32px;">πΈ</span>
|
1560 |
+
</div>
|
1561 |
+
<b>RAG-Anything</b><br>
|
1562 |
+
<sub>Multimodal RAG</sub>
|
1563 |
+
</a>
|
1564 |
+
</td>
|
1565 |
+
<td align="center">
|
1566 |
+
<a href="https://github.com/HKUDS/VideoRAG">
|
1567 |
+
<div style="width: 100px; height: 100px; background: linear-gradient(135deg, rgba(0, 217, 255, 0.1) 0%, rgba(0, 217, 255, 0.05) 100%); border-radius: 15px; border: 1px solid rgba(0, 217, 255, 0.2); display: flex; align-items: center; justify-content: center; margin-bottom: 10px;">
|
1568 |
+
<span style="font-size: 32px;">π₯</span>
|
1569 |
+
</div>
|
1570 |
+
<b>VideoRAG</b><br>
|
1571 |
+
<sub>Extreme Long-Context Video RAG</sub>
|
1572 |
+
</a>
|
1573 |
+
</td>
|
1574 |
+
<td align="center">
|
1575 |
+
<a href="https://github.com/HKUDS/MiniRAG">
|
1576 |
+
<div style="width: 100px; height: 100px; background: linear-gradient(135deg, rgba(0, 217, 255, 0.1) 0%, rgba(0, 217, 255, 0.05) 100%); border-radius: 15px; border: 1px solid rgba(0, 217, 255, 0.2); display: flex; align-items: center; justify-content: center; margin-bottom: 10px;">
|
1577 |
+
<span style="font-size: 32px;">β¨</span>
|
1578 |
+
</div>
|
1579 |
+
<b>MiniRAG</b><br>
|
1580 |
+
<sub>Extremely Simple RAG</sub>
|
1581 |
+
</a>
|
1582 |
+
</td>
|
1583 |
+
</tr>
|
1584 |
+
</table>
|
1585 |
+
</div>
|
1586 |
+
|
1587 |
+
---
|
1588 |
+
|
1589 |
+
## β Star History
|
1590 |
|
1591 |
<a href="https://star-history.com/#HKUDS/LightRAG&Date">
|
1592 |
<picture>
|
|
|
1596 |
</picture>
|
1597 |
</a>
|
1598 |
|
1599 |
+
## π€ Contribution
|
|
|
|
|
1600 |
|
1601 |
+
<div align="center">
|
1602 |
+
We thank all our contributors for their valuable contributions.
|
1603 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1604 |
|
1605 |
+
<div align="center">
|
1606 |
+
<a href="https://github.com/HKUDS/LightRAG/graphs/contributors">
|
1607 |
+
<img src="https://contrib.rocks/image?repo=HKUDS/LightRAG" style="border-radius: 15px; box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);" />
|
1608 |
+
</a>
|
1609 |
+
</div>
|
|
|
|
|
|
|
1610 |
|
1611 |
+
---
|
1612 |
|
|
|
1613 |
|
1614 |
+
## π Citation
|
1615 |
|
1616 |
```python
|
1617 |
@article{guo2024lightrag,
|
|
|
1624 |
}
|
1625 |
```
|
1626 |
|
1627 |
+
---
|
1628 |
+
|
1629 |
+
<div align="center" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 15px; padding: 30px; margin: 30px 0;">
|
1630 |
+
<div>
|
1631 |
+
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="500">
|
1632 |
+
</div>
|
1633 |
+
<div style="margin-top: 20px;">
|
1634 |
+
<a href="https://github.com/HKUDS/LightRAG" style="text-decoration: none;">
|
1635 |
+
<img src="https://img.shields.io/badge/β%20Star%20us%20on%20GitHub-1a1a2e?style=for-the-badge&logo=github&logoColor=white">
|
1636 |
+
</a>
|
1637 |
+
<a href="https://github.com/HKUDS/LightRAG/issues" style="text-decoration: none;">
|
1638 |
+
<img src="https://img.shields.io/badge/π%20Report%20Issues-ff6b6b?style=for-the-badge&logo=github&logoColor=white">
|
1639 |
+
</a>
|
1640 |
+
<a href="https://github.com/HKUDS/LightRAG/discussions" style="text-decoration: none;">
|
1641 |
+
<img src="https://img.shields.io/badge/π¬%20Discussions-4ecdc4?style=for-the-badge&logo=github&logoColor=white">
|
1642 |
+
</a>
|
1643 |
+
</div>
|
1644 |
+
</div>
|
1645 |
+
|
1646 |
+
<div align="center">
|
1647 |
+
<div style="width: 100%; max-width: 600px; margin: 20px auto; padding: 20px; background: linear-gradient(135deg, rgba(0, 217, 255, 0.1) 0%, rgba(0, 217, 255, 0.05) 100%); border-radius: 15px; border: 1px solid rgba(0, 217, 255, 0.2);">
|
1648 |
+
<div style="display: flex; justify-content: center; align-items: center; gap: 15px;">
|
1649 |
+
<span style="font-size: 24px;">β</span>
|
1650 |
+
<span style="color: #00d9ff; font-size: 18px;">Thank you for visiting LightRAG!</span>
|
1651 |
+
<span style="font-size: 24px;">β</span>
|
1652 |
+
</div>
|
1653 |
+
</div>
|
1654 |
+
</div>
|
lightrag/llm/ollama.py
CHANGED
@@ -50,7 +50,7 @@ async def _ollama_model_if_cache(
|
|
50 |
kwargs.pop("max_tokens", None)
|
51 |
# kwargs.pop("response_format", None) # allow json
|
52 |
host = kwargs.pop("host", None)
|
53 |
-
timeout = kwargs.pop("timeout", None) or
|
54 |
kwargs.pop("hashing_kv", None)
|
55 |
api_key = kwargs.pop("api_key", None)
|
56 |
headers = {
|
@@ -146,7 +146,7 @@ async def ollama_embed(texts: list[str], embed_model, **kwargs) -> np.ndarray:
|
|
146 |
headers["Authorization"] = f"Bearer {api_key}"
|
147 |
|
148 |
host = kwargs.pop("host", None)
|
149 |
-
timeout = kwargs.pop("timeout", None) or
|
150 |
|
151 |
ollama_client = ollama.AsyncClient(host=host, timeout=timeout, headers=headers)
|
152 |
|
|
|
50 |
kwargs.pop("max_tokens", None)
|
51 |
# kwargs.pop("response_format", None) # allow json
|
52 |
host = kwargs.pop("host", None)
|
53 |
+
timeout = kwargs.pop("timeout", None) or 600 # Default timeout 600s
|
54 |
kwargs.pop("hashing_kv", None)
|
55 |
api_key = kwargs.pop("api_key", None)
|
56 |
headers = {
|
|
|
146 |
headers["Authorization"] = f"Bearer {api_key}"
|
147 |
|
148 |
host = kwargs.pop("host", None)
|
149 |
+
timeout = kwargs.pop("timeout", None) or 300 # Default time out 300s
|
150 |
|
151 |
ollama_client = ollama.AsyncClient(host=host, timeout=timeout, headers=headers)
|
152 |
|