docs: update README simple example
This commit is contained in:
parent
17d4aca538
commit
6c395d7d7f
1 changed files with 26 additions and 10 deletions
36
README.md
36
README.md
|
|
@ -96,24 +96,40 @@ DB_PASSWORD=cognee
|
|||
|
||||
### Simple example
|
||||
|
||||
Run the default cognee pipeline:
|
||||
First, copy `.env.template` to `.env` and add your OpenAI API key to the LLM_API_KEY field.
|
||||
|
||||
```
|
||||
Optionally, set `VECTOR_DB_PROVIDER="lancedb"` in `.env` to simplify setup.
|
||||
|
||||
This script will run the default pipeline:
|
||||
|
||||
```python
|
||||
import cognee
|
||||
import asyncio
|
||||
from cognee.api.v1.search import SearchType
|
||||
|
||||
text = """Natural language processing (NLP) is an interdisciplinary
|
||||
subfield of computer science and information retrieval"""
|
||||
async def main():
|
||||
await cognee.prune.prune_data() # Reset cognee data
|
||||
await cognee.prune.prune_system(metadata=True) # Reset cognee system state
|
||||
|
||||
await cognee.add(text) # Add a new piece of information
|
||||
text = """
|
||||
Natural language processing (NLP) is an interdisciplinary
|
||||
subfield of computer science and information retrieval.
|
||||
"""
|
||||
|
||||
await cognee.cognify() # Use LLMs and cognee to create a knowledge graph
|
||||
await cognee.add(text) # Add text to cognee
|
||||
await cognee.cognify() # Use LLMs and cognee to create knowledge graph
|
||||
|
||||
search_results = await cognee.search("INSIGHTS", {'query': 'NLP'}) # Query cognee for the insights
|
||||
search_results = await cognee.search( # Search cognee for insights
|
||||
SearchType.INSIGHTS,
|
||||
{'query': 'Tell me about NLP'}
|
||||
)
|
||||
|
||||
for result in search_results:
|
||||
do_something_with_result(result)
|
||||
for result_text in search_results: # Display results
|
||||
print(result_text)
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
A version of this example is here: `examples/pyton/simple_example.py`
|
||||
|
||||
### Create your own memory store
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue