Creating custom tasks in cognee enables you to extend functionality for your specific use case.
Tasks can be any callable in python; functions, asyncronous functions, generators and asyncronous generators.
Copy
Ask AI
# Function taskdef classify_documents(documents: list): # Classify documents and convert them to appropriate data models return classified_documents
Copy
Ask AI
# Async function taskasync def add_data_points(data: list[DataPoint]): # Asyncronously save data into database await save_data_to_db(data) return data
Copy
Ask AI
# Generator taskasync def split_text_into_chunks(text: str): # Use any chunker to split text into chunks return chunks
Copy
Ask AI
# Async generator taskasync def generate_graph_from_chunks(chunks: list): for chunk in chunks: # Asyncronously generate graph from a chunk graph = await generate_graph(chunk) yield graph