Update README.md
This commit is contained in:
159
README.md
159
README.md
@@ -441,11 +441,15 @@ if __name__ == "__main__":
|
|||||||
- [Direct OpenAI Example](examples/lightrag_llamaindex_direct_demo.py)
|
- [Direct OpenAI Example](examples/lightrag_llamaindex_direct_demo.py)
|
||||||
- [LiteLLM Proxy Example](examples/lightrag_llamaindex_litellm_demo.py)
|
- [LiteLLM Proxy Example](examples/lightrag_llamaindex_litellm_demo.py)
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
### Conversation History Support
|
### Conversation History Support
|
||||||
|
|
||||||
|
|
||||||
LightRAG now supports multi-turn dialogue through the conversation history feature. Here's how to use it:
|
LightRAG now supports multi-turn dialogue through the conversation history feature. Here's how to use it:
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# Create conversation history
|
# Create conversation history
|
||||||
conversation_history = [
|
conversation_history = [
|
||||||
@@ -506,6 +510,8 @@ response_custom = rag.query(
|
|||||||
print(response_custom)
|
print(response_custom)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
### Separate Keyword Extraction
|
### Separate Keyword Extraction
|
||||||
|
|
||||||
We've introduced a new function `query_with_separate_keyword_extraction` to enhance the keyword extraction capabilities. This function separates the keyword extraction process from the user's prompt, focusing solely on the query to improve the relevance of extracted keywords.
|
We've introduced a new function `query_with_separate_keyword_extraction` to enhance the keyword extraction capabilities. This function separates the keyword extraction process from the user's prompt, focusing solely on the query to improve the relevance of extracted keywords.
|
||||||
@@ -519,7 +525,8 @@ The function operates by dividing the input into two parts:
|
|||||||
|
|
||||||
It then performs keyword extraction exclusively on the `user query`. This separation ensures that the extraction process is focused and relevant, unaffected by any additional language in the `prompt`. It also allows the `prompt` to serve purely for response formatting, maintaining the intent and clarity of the user's original question.
|
It then performs keyword extraction exclusively on the `user query`. This separation ensures that the extraction process is focused and relevant, unaffected by any additional language in the `prompt`. It also allows the `prompt` to serve purely for response formatting, maintaining the intent and clarity of the user's original question.
|
||||||
|
|
||||||
**Usage Example**
|
<details>
|
||||||
|
<summary> <b> Usage Example </b></summary>
|
||||||
|
|
||||||
This `example` shows how to tailor the function for educational content, focusing on detailed explanations for older students.
|
This `example` shows how to tailor the function for educational content, focusing on detailed explanations for older students.
|
||||||
|
|
||||||
@@ -531,67 +538,6 @@ rag.query_with_separate_keyword_extraction(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Insert Custom KG
|
|
||||||
|
|
||||||
```python
|
|
||||||
custom_kg = {
|
|
||||||
"chunks": [
|
|
||||||
{
|
|
||||||
"content": "Alice and Bob are collaborating on quantum computing research.",
|
|
||||||
"source_id": "doc-1"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"entities": [
|
|
||||||
{
|
|
||||||
"entity_name": "Alice",
|
|
||||||
"entity_type": "person",
|
|
||||||
"description": "Alice is a researcher specializing in quantum physics.",
|
|
||||||
"source_id": "doc-1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"entity_name": "Bob",
|
|
||||||
"entity_type": "person",
|
|
||||||
"description": "Bob is a mathematician.",
|
|
||||||
"source_id": "doc-1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"entity_name": "Quantum Computing",
|
|
||||||
"entity_type": "technology",
|
|
||||||
"description": "Quantum computing utilizes quantum mechanical phenomena for computation.",
|
|
||||||
"source_id": "doc-1"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"relationships": [
|
|
||||||
{
|
|
||||||
"src_id": "Alice",
|
|
||||||
"tgt_id": "Bob",
|
|
||||||
"description": "Alice and Bob are research partners.",
|
|
||||||
"keywords": "collaboration research",
|
|
||||||
"weight": 1.0,
|
|
||||||
"source_id": "doc-1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src_id": "Alice",
|
|
||||||
"tgt_id": "Quantum Computing",
|
|
||||||
"description": "Alice conducts research on quantum computing.",
|
|
||||||
"keywords": "research expertise",
|
|
||||||
"weight": 1.0,
|
|
||||||
"source_id": "doc-1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src_id": "Bob",
|
|
||||||
"tgt_id": "Quantum Computing",
|
|
||||||
"description": "Bob researches quantum computing.",
|
|
||||||
"keywords": "research application",
|
|
||||||
"weight": 1.0,
|
|
||||||
"source_id": "doc-1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
rag.insert_custom_kg(custom_kg)
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Insert
|
## Insert
|
||||||
@@ -683,6 +629,70 @@ rag.insert(text_content.decode('utf-8'))
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary> <b> Insert Custom KG </b></summary>
|
||||||
|
|
||||||
|
```python
|
||||||
|
custom_kg = {
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"content": "Alice and Bob are collaborating on quantum computing research.",
|
||||||
|
"source_id": "doc-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"entity_name": "Alice",
|
||||||
|
"entity_type": "person",
|
||||||
|
"description": "Alice is a researcher specializing in quantum physics.",
|
||||||
|
"source_id": "doc-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity_name": "Bob",
|
||||||
|
"entity_type": "person",
|
||||||
|
"description": "Bob is a mathematician.",
|
||||||
|
"source_id": "doc-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity_name": "Quantum Computing",
|
||||||
|
"entity_type": "technology",
|
||||||
|
"description": "Quantum computing utilizes quantum mechanical phenomena for computation.",
|
||||||
|
"source_id": "doc-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"relationships": [
|
||||||
|
{
|
||||||
|
"src_id": "Alice",
|
||||||
|
"tgt_id": "Bob",
|
||||||
|
"description": "Alice and Bob are research partners.",
|
||||||
|
"keywords": "collaboration research",
|
||||||
|
"weight": 1.0,
|
||||||
|
"source_id": "doc-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src_id": "Alice",
|
||||||
|
"tgt_id": "Quantum Computing",
|
||||||
|
"description": "Alice conducts research on quantum computing.",
|
||||||
|
"keywords": "research expertise",
|
||||||
|
"weight": 1.0,
|
||||||
|
"source_id": "doc-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src_id": "Bob",
|
||||||
|
"tgt_id": "Quantum Computing",
|
||||||
|
"description": "Bob researches quantum computing.",
|
||||||
|
"keywords": "research application",
|
||||||
|
"weight": 1.0,
|
||||||
|
"source_id": "doc-1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
rag.insert_custom_kg(custom_kg)
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><b>Citation Functionality</b></summary>
|
<summary><b>Citation Functionality</b></summary>
|
||||||
|
|
||||||
@@ -842,7 +852,8 @@ rag.delete_by_doc_id("doc_id")
|
|||||||
|
|
||||||
LightRAG now supports comprehensive knowledge graph management capabilities, allowing you to create, edit, and delete entities and relationships within your knowledge graph.
|
LightRAG now supports comprehensive knowledge graph management capabilities, allowing you to create, edit, and delete entities and relationships within your knowledge graph.
|
||||||
|
|
||||||
### Create Entities and Relations
|
<details>
|
||||||
|
<summary> <b> Create Entities and Relations </b></summary>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# Create new entity
|
# Create new entity
|
||||||
@@ -865,7 +876,10 @@ relation = rag.create_relation("Google", "Gmail", {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Edit Entities and Relations
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary> <b> Edit Entities and Relations </b></summary>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# Edit an existing entity
|
# Edit an existing entity
|
||||||
@@ -902,6 +916,8 @@ All operations are available in both synchronous and asynchronous versions. The
|
|||||||
|
|
||||||
These operations maintain data consistency across both the graph database and vector database components, ensuring your knowledge graph remains coherent.
|
These operations maintain data consistency across both the graph database and vector database components, ensuring your knowledge graph remains coherent.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Data Export Functions
|
## Data Export Functions
|
||||||
|
|
||||||
### Overview
|
### Overview
|
||||||
@@ -910,7 +926,8 @@ LightRAG allows you to export your knowledge graph data in various formats for a
|
|||||||
|
|
||||||
### Export Functions
|
### Export Functions
|
||||||
|
|
||||||
#### Basic Usage
|
<details>
|
||||||
|
<summary> <b> Basic Usage </b></summary>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# Basic CSV export (default format)
|
# Basic CSV export (default format)
|
||||||
@@ -920,7 +937,10 @@ rag.export_data("knowledge_graph.csv")
|
|||||||
rag.export_data("output.xlsx", file_format="excel")
|
rag.export_data("output.xlsx", file_format="excel")
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Different File Formats supported
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary> <b> Different File Formats supported </b></summary>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
#Export data in CSV format
|
#Export data in CSV format
|
||||||
@@ -935,13 +955,18 @@ rag.export_data("graph_data.md", file_format="md")
|
|||||||
# Export data in Text
|
# Export data in Text
|
||||||
rag.export_data("graph_data.txt", file_format="txt")
|
rag.export_data("graph_data.txt", file_format="txt")
|
||||||
```
|
```
|
||||||
#### Additional Options
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary> <b> Additional Options </b></summary>
|
||||||
|
|
||||||
Include vector embeddings in the export (optional):
|
Include vector embeddings in the export (optional):
|
||||||
|
|
||||||
```python
|
```python
|
||||||
rag.export_data("complete_data.csv", include_vector_data=True)
|
rag.export_data("complete_data.csv", include_vector_data=True)
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
### Data Included in Export
|
### Data Included in Export
|
||||||
|
|
||||||
All exports include:
|
All exports include:
|
||||||
|
Reference in New Issue
Block a user