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

Feature/cog 186 run cognee on windows #449

Merged
merged 11 commits into from
Jan 17, 2025
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import os
os.environ["LLM_API_KEY"] = "YOUR OPENAI_API_KEY"

```
or
or
```
import cognee
cognee.config.set_llm_api_key("YOUR_OPENAI_API_KEY")
Expand Down Expand Up @@ -115,7 +115,7 @@ DB_PORT=5432
DB_NAME=cognee_db
DB_USERNAME=cognee
DB_PASSWORD=cognee
```
```

### Simple example

Expand All @@ -140,14 +140,14 @@ async def main():
Natural language processing (NLP) is an interdisciplinary
subfield of computer science and information retrieval.
"""

print("Adding text to cognee:")
print(text.strip())
print(text.strip())
# Add the text, and make it available for cognify
await cognee.add(text)
print("Text added successfully.\n")


print("Running cognify to create knowledge graph...\n")
print("Cognify process steps:")
print("1. Classifying the document: Determining the type and category of the input text.")
Expand All @@ -156,19 +156,19 @@ async def main():
print("4. Adding data points: Storing the extracted chunks for processing.")
print("5. Generating knowledge graph: Extracting entities and relationships to form a knowledge graph.")
print("6. Summarizing text: Creating concise summaries of the content for quick insights.\n")

# Use LLMs and cognee to create knowledge graph
await cognee.cognify()
print("Cognify process complete.\n")


query_text = 'Tell me about NLP'
print(f"Searching cognee for insights with query: '{query_text}'")
# Query cognee for insights on the added text
search_results = await cognee.search(
SearchType.INSIGHTS, query_text=query_text
)

print("Search results:")
# Display results
for result_text in search_results:
Expand Down Expand Up @@ -212,7 +212,7 @@ Cognee supports a variety of tools and services for different operations:
- **Language Models (LLMs)**: You can use either Anyscale or Ollama as your LLM provider.

- **Graph Stores**: In addition to NetworkX, Neo4j is also supported for graph storage.

- **User management**: Create individual user graphs and manage permissions

## Demo
Expand Down Expand Up @@ -258,13 +258,13 @@ pip install cognee



| Name | Type | Current state | Known Issues |
|----------|--------------------|-------------------|--------------|
| Qdrant | Vector | Stable ✅ | |
| Weaviate | Vector | Stable ✅ | |
| LanceDB | Vector | Stable ✅ | |
| Neo4j | Graph | Stable ✅ | |
| NetworkX | Graph | Stable ✅ | |
| FalkorDB | Vector/Graph | Unstable ❌ | |
| PGVector | Vector | Stable ✅ | |
| Milvus | Vector | Stable ✅ | |
| Name | Type | Current state (Mac/Linux) | Known Issues | Current state (Win) | Known Issues |
|----------|--------------------|---------------------------|--------------|---------------------|--------------|
| Qdrant | Vector | Stable ✅ | | Untested ⏳ | |
| Weaviate | Vector | Stable ✅ | | Untested ⏳ | |
| LanceDB | Vector | Stable ✅ | | Stable ✅ | |
| Neo4j | Graph | Stable ✅ | | Stable ✅ | |
| NetworkX | Graph | Stable ✅ | | Stable ✅ | |
| FalkorDB | Vector/Graph | Unstable ❌ | | Unstable ❌ | |
| PGVector | Vector | Stable ✅ | | Unstable ❌ | |
| Milvus | Vector | Stable ✅ | | Untested ⏳ | |
15 changes: 12 additions & 3 deletions cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ async def get_distance_from_collection_elements(
connection = await self.get_connection()
collection = await connection.open_table(collection_name)

results = await collection.vector_search(query_vector).to_pandas()
collection_size = await collection.count_rows()

results = await collection.vector_search(query_vector).limit(collection_size).to_pandas()

result_values = list(results.to_dict("index").values())

Expand Down Expand Up @@ -250,9 +252,16 @@ async def index_data_points(
)

async def prune(self):
# Clean up the database if it was set up as temporary
connection = await self.get_connection()
collection_names = await connection.table_names()

for collection_name in collection_names:
collection = await connection.open_table(collection_name)
await collection.delete("id IS NOT NULL")
await connection.drop_table(collection_name)

if self.url.startswith("/"):
LocalStorage.remove_all(self.url) # Remove the temporary directory and files inside
LocalStorage.remove_all(self.url)
hajdul88 marked this conversation as resolved.
Show resolved Hide resolved

def get_data_point_schema(self, model_type):
return copy_model(
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ if [ "$ENVIRONMENT" = "dev" ]; then
else
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level error cognee.api.client:app
# python ./cognee/api/client.py
fi
fi
7 changes: 6 additions & 1 deletion examples/python/dynamic_steps_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,9 @@ async def main(enable_steps):
"retriever": retrieve,
}

asyncio.run(main(steps_to_enable))
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(main(steps_to_enable))
finally:
loop.run_until_complete(loop.shutdown_asyncgens())
7 changes: 6 additions & 1 deletion examples/python/graphiti_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ async def main():

if __name__ == "__main__":
setup_logging(logging.ERROR)
asyncio.run(main())
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(main())
finally:
loop.run_until_complete(loop.shutdown_asyncgens())
10 changes: 9 additions & 1 deletion examples/python/multimedia_example.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
import asyncio
import pathlib
import logging

import cognee
from cognee.api.v1.search import SearchType
from cognee.shared.utils import setup_logging

# Prerequisites:
# 1. Copy `.env.template` and rename it to `.env`.
Expand Down Expand Up @@ -45,4 +47,10 @@ async def main():


if __name__ == "__main__":
asyncio.run(main())
setup_logging(logging.ERROR)
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(main())
finally:
loop.run_until_complete(loop.shutdown_asyncgens())
10 changes: 9 additions & 1 deletion examples/python/simple_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import asyncio
import cognee
import logging
from cognee.api.v1.search import SearchType
from cognee.shared.utils import setup_logging

# Prerequisites:
# 1. Copy `.env.template` and rename it to `.env`.
Expand Down Expand Up @@ -66,4 +68,10 @@ async def main():


if __name__ == "__main__":
asyncio.run(main())
setup_logging(logging.ERROR)
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(main())
finally:
loop.run_until_complete(loop.shutdown_asyncgens())
Loading