mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-09-11 14:36:35 +03:00
Merge branch 'main' into fix/disabledKnowledgeTab
This commit is contained in:
commit
a1b52a6074
@ -59,7 +59,7 @@ class NotionConnector(IntegrationBrain, Integration):
|
|||||||
def _load_credentials(self) -> dict[str, str]:
|
def _load_credentials(self) -> dict[str, str]:
|
||||||
"""Load the Notion credentials"""
|
"""Load the Notion credentials"""
|
||||||
self.integration_details = self.get_integration_brain(
|
self.integration_details = self.get_integration_brain(
|
||||||
self.brain_id, self.user_id
|
self.brain_id
|
||||||
)
|
)
|
||||||
if self.credentials is None:
|
if self.credentials is None:
|
||||||
logger.info("Loading Notion credentials")
|
logger.info("Loading Notion credentials")
|
||||||
@ -343,7 +343,7 @@ class NotionConnector(IntegrationBrain, Integration):
|
|||||||
"""
|
"""
|
||||||
Update all the brains with the latest data from Notion
|
Update all the brains with the latest data from Notion
|
||||||
"""
|
"""
|
||||||
integration = self.get_integration_brain(self.brain_id, self.user_id)
|
integration = self.get_integration_brain(self.brain_id)
|
||||||
last_synced = integration.last_synced
|
last_synced = integration.last_synced
|
||||||
|
|
||||||
query_dict = {
|
query_dict = {
|
||||||
|
@ -26,7 +26,7 @@ class SQLConnector(IntegrationBrain):
|
|||||||
def _load_credentials(self) -> dict[str, str]:
|
def _load_credentials(self) -> dict[str, str]:
|
||||||
"""Load the Notion credentials"""
|
"""Load the Notion credentials"""
|
||||||
self.integration_details = self.get_integration_brain(
|
self.integration_details = self.get_integration_brain(
|
||||||
self.brain_id, self.user_id
|
self.brain_id
|
||||||
)
|
)
|
||||||
if self.credentials is None:
|
if self.credentials is None:
|
||||||
logger.info("Loading Notion credentials")
|
logger.info("Loading Notion credentials")
|
||||||
|
@ -33,14 +33,18 @@ class IntegrationBrain(IntegrationBrainInterface):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.db = get_supabase_client()
|
self.db = get_supabase_client()
|
||||||
|
|
||||||
def get_integration_brain(self, brain_id, user_id):
|
def get_integration_brain(self, brain_id, user_id = None):
|
||||||
response = (
|
query = (
|
||||||
self.db.table("integrations_user")
|
self.db.table("integrations_user")
|
||||||
.select("*")
|
.select("*")
|
||||||
.filter("brain_id", "eq", brain_id)
|
.filter("brain_id", "eq", brain_id)
|
||||||
.filter("user_id", "eq", user_id)
|
|
||||||
.execute()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if user_id:
|
||||||
|
query.filter("user_id", "eq", user_id)
|
||||||
|
|
||||||
|
response = query.execute()
|
||||||
|
|
||||||
if len(response.data) == 0:
|
if len(response.data) == 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class BrainsInterface(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_brain_details(self, brain_id: UUID) -> BrainEntity | None:
|
def get_brain_details(self, brain_id: UUID, user_id: UUID) -> BrainEntity | None:
|
||||||
"""
|
"""
|
||||||
Get all public brains
|
Get all public brains
|
||||||
"""
|
"""
|
||||||
|
@ -9,7 +9,7 @@ from modules.brain.entity.integration_brain import (
|
|||||||
|
|
||||||
class IntegrationBrainInterface(ABC):
|
class IntegrationBrainInterface(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_integration_brain(self, brain_id: UUID, user_id: UUID) -> IntegrationEntity:
|
def get_integration_brain(self, brain_id: UUID) -> IntegrationEntity:
|
||||||
"""Get the integration brain entity
|
"""Get the integration brain entity
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -58,9 +58,9 @@ class BrainService:
|
|||||||
def get_brain_by_id(self, brain_id: UUID):
|
def get_brain_by_id(self, brain_id: UUID):
|
||||||
return self.brain_repository.get_brain_by_id(brain_id)
|
return self.brain_repository.get_brain_by_id(brain_id)
|
||||||
|
|
||||||
def get_integration_brain(self, brain_id, user_id) -> IntegrationEntity | None:
|
def get_integration_brain(self, brain_id) -> IntegrationEntity | None:
|
||||||
return self.integration_brains_repository.get_integration_brain(
|
return self.integration_brains_repository.get_integration_brain(
|
||||||
brain_id, user_id
|
brain_id
|
||||||
)
|
)
|
||||||
|
|
||||||
def find_brain_from_question(
|
def find_brain_from_question(
|
||||||
@ -323,7 +323,7 @@ class BrainService:
|
|||||||
def update_brain_last_update_time(self, brain_id: UUID):
|
def update_brain_last_update_time(self, brain_id: UUID):
|
||||||
self.brain_repository.update_brain_last_update_time(brain_id)
|
self.brain_repository.update_brain_last_update_time(brain_id)
|
||||||
|
|
||||||
def get_brain_details(self, brain_id: UUID, user_id: UUID) -> BrainEntity | None:
|
def get_brain_details(self, brain_id: UUID, user_id: UUID = None) -> BrainEntity | None:
|
||||||
brain = self.brain_repository.get_brain_details(brain_id)
|
brain = self.brain_repository.get_brain_details(brain_id)
|
||||||
if brain == None:
|
if brain == None:
|
||||||
return None
|
return None
|
||||||
@ -334,6 +334,14 @@ class BrainService:
|
|||||||
brain_id, user_id
|
brain_id, user_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (brain.integration):
|
||||||
|
brain.integration_description = (
|
||||||
|
self.integration_description_repository.get_integration_description(
|
||||||
|
brain.integration.integration_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return brain
|
return brain
|
||||||
|
|
||||||
def get_connected_brains(self, brain_id: UUID) -> list[BrainEntity]:
|
def get_connected_brains(self, brain_id: UUID) -> list[BrainEntity]:
|
||||||
|
Loading…
Reference in New Issue
Block a user