refactor: Update examples to use pprint (#1921)
<!-- .github/pull_request_template.md -->
## Description
Update examples to use pprint
## Acceptance Criteria
<!--
* Key requirements to the new feature or modification;
* Proof that the changes work and meet the requirements;
* Include instructions on how to verify the changes. Describe how to
test it locally;
* Proof that it's sufficiently tested.
-->
## Type of Change
<!-- Please check the relevant option -->
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Other (please specify):
## Screenshots/Videos (if applicable)
<!-- Add screenshots or videos to help explain your changes -->
## Pre-submission Checklist
<!-- Please check all boxes that apply before submitting your PR -->
- [ ] **I have tested my changes thoroughly before submitting this PR**
- [ ] **This PR contains minimal changes necessary to address the
issue/feature**
- [ ] My code follows the project's coding standards and style
guidelines
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added necessary documentation (if applicable)
- [ ] All new and existing tests pass
- [ ] I have searched existing PRs to ensure this change hasn't been
submitted already
- [ ] I have linked any relevant issues in the description
- [ ] My commits have clear and descriptive messages
## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Style**
* Updated Python examples to use prettier, more readable output
formatting for search and example results.
* **Documentation**
* README updated to reflect improved example output presentation, making
demonstrations easier to read and verify.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
commit
d8d3844805
10 changed files with 35 additions and 21 deletions
|
|
@ -126,6 +126,7 @@ Now, run a minimal pipeline:
|
|||
```python
|
||||
import cognee
|
||||
import asyncio
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
async def main():
|
||||
|
|
@ -143,7 +144,7 @@ async def main():
|
|||
|
||||
# Display the results
|
||||
for result in results:
|
||||
print(result)
|
||||
pprint(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import asyncio
|
||||
import cognee
|
||||
|
||||
import os
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
# By default cognee uses OpenAI's gpt-5-mini LLM model
|
||||
# Provide your OpenAI LLM API KEY
|
||||
os.environ["LLM_API_KEY"] = ""
|
||||
|
|
@ -24,13 +25,13 @@ async def cognee_demo():
|
|||
|
||||
# Query Cognee for information from provided document
|
||||
answer = await cognee.search("List me all the important characters in Alice in Wonderland.")
|
||||
print(answer)
|
||||
pprint(answer)
|
||||
|
||||
answer = await cognee.search("How did Alice end up in Wonderland?")
|
||||
print(answer)
|
||||
pprint(answer)
|
||||
|
||||
answer = await cognee.search("Tell me about Alice's personality.")
|
||||
print(answer)
|
||||
pprint(answer)
|
||||
|
||||
|
||||
# Cognee is an async library, it has to be called in an async context
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import asyncio
|
||||
from pprint import pprint
|
||||
|
||||
import cognee
|
||||
from cognee.api.v1.search import SearchType
|
||||
|
|
@ -187,7 +188,7 @@ async def main(enable_steps):
|
|||
search_results = await cognee.search(
|
||||
query_type=SearchType.GRAPH_COMPLETION, query_text="Who has experience in design tools?"
|
||||
)
|
||||
print(search_results)
|
||||
pprint(search_results)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
import asyncio
|
||||
import pathlib
|
||||
from pprint import pprint
|
||||
|
||||
from cognee.shared.logging_utils import setup_logging, ERROR
|
||||
|
||||
import cognee
|
||||
|
|
@ -42,7 +44,7 @@ async def main():
|
|||
|
||||
# Display search results
|
||||
for result_text in search_results:
|
||||
print(result_text)
|
||||
pprint(result_text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import asyncio
|
||||
import os
|
||||
from pprint import pprint
|
||||
|
||||
import cognee
|
||||
from cognee.api.v1.search import SearchType
|
||||
|
|
@ -77,7 +78,7 @@ async def main():
|
|||
query_type=SearchType.GRAPH_COMPLETION,
|
||||
query_text="What are the exact cars and their types produced by Audi?",
|
||||
)
|
||||
print(search_results)
|
||||
pprint(search_results)
|
||||
|
||||
await visualize_graph()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import cognee
|
||||
import pathlib
|
||||
from pprint import pprint
|
||||
|
||||
from cognee.modules.users.exceptions import PermissionDeniedError
|
||||
from cognee.modules.users.tenants.methods import select_tenant
|
||||
|
|
@ -86,7 +87,7 @@ async def main():
|
|||
)
|
||||
print("\nSearch results as user_1 on dataset owned by user_1:")
|
||||
for result in search_results:
|
||||
print(f"{result}\n")
|
||||
pprint(result)
|
||||
|
||||
# But user_1 cant read the dataset owned by user_2 (QUANTUM dataset)
|
||||
print("\nSearch result as user_1 on the dataset owned by user_2:")
|
||||
|
|
@ -134,7 +135,7 @@ async def main():
|
|||
dataset_ids=[quantum_dataset_id],
|
||||
)
|
||||
for result in search_results:
|
||||
print(f"{result}\n")
|
||||
pprint(result)
|
||||
|
||||
# If we'd like for user_1 to add new documents to the QUANTUM dataset owned by user_2, user_1 would have to get
|
||||
# "write" access permission, which user_1 currently does not have
|
||||
|
|
@ -217,7 +218,7 @@ async def main():
|
|||
dataset_ids=[quantum_cognee_lab_dataset_id],
|
||||
)
|
||||
for result in search_results:
|
||||
print(f"{result}\n")
|
||||
pprint(result)
|
||||
|
||||
# Note: All of these function calls and permission system is available through our backend endpoints as well
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import asyncio
|
||||
from pprint import pprint
|
||||
|
||||
import cognee
|
||||
from cognee.modules.engine.operations.setup import setup
|
||||
from cognee.modules.users.methods import get_default_user
|
||||
|
|
@ -71,7 +73,7 @@ async def main():
|
|||
print("Search results:")
|
||||
# Display results
|
||||
for result_text in search_results:
|
||||
print(result_text)
|
||||
pprint(result_text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import asyncio
|
||||
from pprint import pprint
|
||||
|
||||
import cognee
|
||||
from cognee.shared.logging_utils import setup_logging, ERROR
|
||||
from cognee.api.v1.search import SearchType
|
||||
|
|
@ -54,7 +56,7 @@ async def main():
|
|||
print("Search results:")
|
||||
# Display results
|
||||
for result_text in search_results:
|
||||
print(result_text)
|
||||
pprint(result_text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import asyncio
|
||||
from pprint import pprint
|
||||
import cognee
|
||||
from cognee.shared.logging_utils import setup_logging, INFO
|
||||
from cognee.api.v1.search import SearchType
|
||||
|
|
@ -87,7 +88,8 @@ async def main():
|
|||
top_k=15,
|
||||
)
|
||||
print(f"Query: {query_text}")
|
||||
print(f"Results: {search_results}\n")
|
||||
print("Results:")
|
||||
pprint(search_results)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import asyncio
|
||||
from pprint import pprint
|
||||
|
||||
import cognee
|
||||
from cognee.memify_pipelines.create_triplet_embeddings import create_triplet_embeddings
|
||||
|
|
@ -65,7 +66,7 @@ async def main():
|
|||
query_type=SearchType.TRIPLET_COMPLETION,
|
||||
query_text="What are the models produced by Volkswagen based on the context?",
|
||||
)
|
||||
print(search_results)
|
||||
pprint(search_results)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue