Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixes faulty logging format and sets up error logging in dynamic… #412

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cognee/shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import matplotlib.pyplot as plt
import tiktoken
import nltk
import logging
import sys

from cognee.base_config import get_base_config
from cognee.infrastructure.databases.graph import get_graph_engine
Expand Down Expand Up @@ -283,6 +285,18 @@ def extract_sentiment_vader(text):

return polarity_scores

def setup_logging(log_level=logging.INFO):
""" This method sets up the logging configuration. """
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s\n")
stream_handler = logging.StreamHandler(sys.stdout)
stream_handler.setFormatter(formatter)
stream_handler.setLevel(log_level)

logging.basicConfig(
level=log_level,
handlers=[stream_handler],
)

hajdul88 marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":
sample_text = "I love sunny days, but I hate the rain."
Expand Down
4 changes: 4 additions & 0 deletions examples/python/dynamic_steps_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import cognee
import asyncio
import logging
from cognee.modules.retrieval.brute_force_triplet_search import brute_force_triplet_search
from cognee.modules.retrieval.brute_force_triplet_search import format_triplets
from cognee.shared.utils import setup_logging

job_1 = """
CV 1: Relevant
Expand Down Expand Up @@ -186,6 +188,8 @@ async def main(enable_steps):
print(format_triplets(results))

if __name__ == '__main__':
setup_logging(logging.ERROR)

hajdul88 marked this conversation as resolved.
Show resolved Hide resolved
rebuild_kg = True
retrieve = True
steps_to_enable = {
Expand Down
Loading