Query with your custom prompts
This commit is contained in:
31
README.md
31
README.md
@@ -159,7 +159,38 @@ response = rag.query(
|
||||
)
|
||||
```
|
||||
|
||||
### Custom Prompt Support
|
||||
LightRAG now supports custom prompts for fine-tuned control over the system's behavior. Here's how to use it:
|
||||
|
||||
```python
|
||||
from lightrag import LightRAG, QueryParam
|
||||
|
||||
# Initialize LightRAG
|
||||
rag = LightRAG(working_dir=WORKING_DIR)
|
||||
|
||||
# Create query parameters
|
||||
query_param = QueryParam(
|
||||
mode="hybrid", # or other mode: "local", "global", "hybrid"
|
||||
)
|
||||
|
||||
# Example 1: Using the default system prompt
|
||||
response_default = rag.query(
|
||||
"What are the primary benefits of renewable energy?",
|
||||
param=query_param
|
||||
)
|
||||
print(response_default)
|
||||
|
||||
# Example 2: Using a custom prompt
|
||||
custom_prompt = """
|
||||
You are an expert assistant in environmental science. Provide detailed and structured answers with examples.
|
||||
"""
|
||||
response_custom = rag.query(
|
||||
"What are the primary benefits of renewable energy?",
|
||||
param=query_param,
|
||||
prompt=custom_prompt # Pass the custom prompt
|
||||
)
|
||||
print(response_custom)
|
||||
```
|
||||
|
||||
|
||||
<details>
|
||||
|
Reference in New Issue
Block a user