Updates to functions

This commit is contained in:
Vasilije 2024-07-27 16:18:08 +02:00
parent 797e7baba3
commit 66749fadc2
2 changed files with 20 additions and 5 deletions

View file

@ -86,7 +86,7 @@ async def add_files(file_paths: List[str], dataset_name: str, user_id: str = "d
) )
@dlt.resource(standalone = True, merge_key = "id") @dlt.resource(standalone = True, merge_key = "id")
def data_resources(file_paths: str, user_id: str = user_id): async def data_resources(file_paths: str, user_id: str = user_id):
for file_path in file_paths: for file_path in file_paths:
with open(file_path.replace("file://", ""), mode = "rb") as file: with open(file_path.replace("file://", ""), mode = "rb") as file:
classified_data = ingestion.classify(file) classified_data = ingestion.classify(file)
@ -94,9 +94,9 @@ async def add_files(file_paths: List[str], dataset_name: str, user_id: str = "d
data_id = ingestion.identify(classified_data) data_id = ingestion.identify(classified_data)
async with get_async_session_context() as session: async with get_async_session_context() as session:
if user_id is None: if user_id is None:
current_active_user = create_default_user() current_active_user = await create_default_user()
give_permission_document(current_active_user, data_id, "write", session= session) await give_permission_document(current_active_user, data_id, "write", session= session)
file_metadata = classified_data.get_metadata() file_metadata = classified_data.get_metadata()

View file

@ -1,9 +1,24 @@
from cognee.infrastructure.databases.relational.user_authentication.users import authenticate_user_method from cognee.infrastructure.databases.relational.user_authentication.users import authenticate_user_method
async def authenticate_user(): async def authenticate_user(email: str, password: str):
""" """
This function is used to authenticate a user. This function is used to authenticate a user.
""" """
output = await authenticate_user_method() output = await authenticate_user_method(email=email, password=password)
return output return output
if __name__ == "__main__":
import asyncio
# Define an example user
example_email = "example@example.com"
example_password = "securepassword123"
example_is_superuser = False
# Create an event loop and run the create_user function
loop = asyncio.get_event_loop()
result = loop.run_until_complete(authenticate_user(example_email, example_password))
# Print the result
print(result)