chore: linting and formatting

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-09-28 22:26:26 -07:00
parent ef361e16b4
commit 94367e4226
16 changed files with 143 additions and 131 deletions

View file

@ -421,13 +421,14 @@ async def fetch_documents_by_ids(
start_time = metadata.get("start_time", "") start_time = metadata.get("start_time", "")
location_name = metadata.get("location_name", "") location_name = metadata.get("location_name", "")
meeting_url = metadata.get("meeting_url", "") meeting_url = metadata.get("meeting_url", "")
title = f"Luma: {event_name}" title = f"Luma: {event_name}"
if start_time: if start_time:
# Format the start time for display # Format the start time for display
try: try:
if "T" in start_time: if "T" in start_time:
from datetime import datetime from datetime import datetime
start_dt = datetime.fromisoformat( start_dt = datetime.fromisoformat(
start_time.replace("Z", "+00:00") start_time.replace("Z", "+00:00")
) )
@ -435,7 +436,7 @@ async def fetch_documents_by_ids(
title += f" ({formatted_time})" title += f" ({formatted_time})"
except Exception: except Exception:
pass pass
description = ( description = (
doc.content[:100] + "..." doc.content[:100] + "..."
if len(doc.content) > 100 if len(doc.content) > 100
@ -444,8 +445,8 @@ async def fetch_documents_by_ids(
if location_name: if location_name:
description += f" | Venue: {location_name}" description += f" | Venue: {location_name}"
elif meeting_url: elif meeting_url:
description += f" | Online Event" description += " | Online Event"
url = event_url if event_url else "" url = event_url if event_url else ""
elif doc_type == "EXTENSION": elif doc_type == "EXTENSION":

View file

@ -82,7 +82,9 @@ class LumaConnector:
elif response.status_code == 401: elif response.status_code == 401:
raise Exception("Unauthorized: Invalid Luma API key") raise Exception("Unauthorized: Invalid Luma API key")
elif response.status_code == 403: elif response.status_code == 403:
raise Exception("Forbidden: Access denied or Luma Plus subscription required") raise Exception(
"Forbidden: Access denied or Luma Plus subscription required"
)
elif response.status_code == 429: elif response.status_code == 429:
raise Exception("Rate limit exceeded: Too many requests") raise Exception("Rate limit exceeded: Too many requests")
else: else:
@ -106,7 +108,9 @@ class LumaConnector:
except Exception as e: except Exception as e:
return None, f"Error fetching user info: {e!s}" return None, f"Error fetching user info: {e!s}"
def get_all_events(self, limit: int = 100) -> tuple[list[dict[str, Any]], str | None]: def get_all_events(
self, limit: int = 100
) -> tuple[list[dict[str, Any]], str | None]:
""" """
Fetch all events for the authenticated user. Fetch all events for the authenticated user.
@ -119,32 +123,34 @@ class LumaConnector:
try: try:
all_events = [] all_events = []
cursor = None cursor = None
while True: while True:
params = {"limit": limit} params = {"limit": limit}
if cursor: if cursor:
params["cursor"] = cursor params["cursor"] = cursor
response = self.make_request("calendar/list-events", params) response = self.make_request("calendar/list-events", params)
if "entries" not in response: if "entries" not in response:
break break
events = response["entries"] events = response["entries"]
all_events.extend(events) all_events.extend(events)
# Check for pagination # Check for pagination
if "next_cursor" in response and response["next_cursor"]: if response.get("next_cursor"):
cursor = response["next_cursor"] cursor = response["next_cursor"]
else: else:
break break
return all_events, None return all_events, None
except Exception as e: except Exception as e:
return [], f"Error fetching events: {e!s}" return [], f"Error fetching events: {e!s}"
def get_event_details(self, event_id: str) -> tuple[dict[str, Any] | None, str | None]: def get_event_details(
self, event_id: str
) -> tuple[dict[str, Any] | None, str | None]:
""" """
Fetch detailed information about a specific event. Fetch detailed information about a specific event.
@ -160,7 +166,9 @@ class LumaConnector:
except Exception as e: except Exception as e:
return None, f"Error fetching event details for {event_id}: {e!s}" return None, f"Error fetching event details for {event_id}: {e!s}"
def get_event_guests(self, event_id: str, limit: int = 100) -> tuple[list[dict[str, Any]], str | None]: def get_event_guests(
self, event_id: str, limit: int = 100
) -> tuple[list[dict[str, Any]], str | None]:
""" """
Fetch guests for a specific event. Fetch guests for a specific event.
@ -174,26 +182,26 @@ class LumaConnector:
try: try:
all_guests = [] all_guests = []
cursor = None cursor = None
while True: while True:
params = {"limit": limit} params = {"limit": limit}
if cursor: if cursor:
params["cursor"] = cursor params["cursor"] = cursor
response = self.make_request(f"events/{event_id}/guests", params) response = self.make_request(f"events/{event_id}/guests", params)
if "entries" not in response: if "entries" not in response:
break break
guests = response["entries"] guests = response["entries"]
all_guests.extend(guests) all_guests.extend(guests)
# Check for pagination # Check for pagination
if "next_cursor" in response and response["next_cursor"]: if response.get("next_cursor"):
cursor = response["next_cursor"] cursor = response["next_cursor"]
else: else:
break break
return all_guests, None return all_guests, None
except Exception as e: except Exception as e:
@ -217,7 +225,7 @@ class LumaConnector:
# Convert date strings to ISO format for comparison # Convert date strings to ISO format for comparison
start_dt = datetime.strptime(start_date, "%Y-%m-%d") start_dt = datetime.strptime(start_date, "%Y-%m-%d")
end_dt = datetime.strptime(end_date, "%Y-%m-%d") end_dt = datetime.strptime(end_date, "%Y-%m-%d")
# Get all events first # Get all events first
all_events, error = self.get_all_events() all_events, error = self.get_all_events()
if error: if error:
@ -230,19 +238,23 @@ class LumaConnector:
if event_start_time: if event_start_time:
try: try:
# Parse the event start time (assuming ISO format) # Parse the event start time (assuming ISO format)
event_dt = datetime.fromisoformat(event_start_time.replace("Z", "+00:00")) event_dt = datetime.fromisoformat(
event_start_time.replace("Z", "+00:00")
)
event_date = event_dt.date() event_date = event_dt.date()
# Check if event falls within the date range # Check if event falls within the date range
if start_dt.date() <= event_date <= end_dt.date(): if start_dt.date() <= event_date <= end_dt.date():
# Add guest information if requested # Add guest information if requested
if include_guests: if include_guests:
event_id = event.get("api_id") event_id = event.get("api_id")
if event_id: if event_id:
guests, guest_error = self.get_event_guests(event_id) guests, guest_error = self.get_event_guests(
event_id
)
if not guest_error: if not guest_error:
event["guests"] = guests event["guests"] = guests
filtered_events.append(event) filtered_events.append(event)
except (ValueError, AttributeError): except (ValueError, AttributeError):
# Skip events with invalid dates # Skip events with invalid dates
@ -270,45 +282,45 @@ class LumaConnector:
""" """
# Extract event details # Extract event details
event_data = event.get("event", {}) event_data = event.get("event", {})
title = event_data.get("name", "Untitled Event") title = event_data.get("name", "Untitled Event")
description = event_data.get("description", "") description = event_data.get("description", "")
event_id = event.get("api_id", "") event_id = event.get("api_id", "")
# Extract timing information # Extract timing information
start_at = event_data.get("start_at", "") start_at = event_data.get("start_at", "")
end_at = event_data.get("end_at", "") end_at = event_data.get("end_at", "")
timezone = event_data.get("timezone", "") timezone = event_data.get("timezone", "")
# Format dates # Format dates
start_formatted = self.format_date(start_at) if start_at else "Unknown" start_formatted = self.format_date(start_at) if start_at else "Unknown"
end_formatted = self.format_date(end_at) if end_at else "Unknown" end_formatted = self.format_date(end_at) if end_at else "Unknown"
# Extract location information # Extract location information
geo_info = event_data.get("geo_info", {}) geo_info = event_data.get("geo_info", {})
location_name = geo_info.get("name", "") location_name = geo_info.get("name", "")
address = geo_info.get("address", "") address = geo_info.get("address", "")
# Extract other details # Extract other details
url = event_data.get("url", "") url = event_data.get("url", "")
visibility = event_data.get("visibility", "") visibility = event_data.get("visibility", "")
meeting_url = event_data.get("meeting_url", "") meeting_url = event_data.get("meeting_url", "")
# Build markdown content # Build markdown content
markdown_content = f"# {title}\n\n" markdown_content = f"# {title}\n\n"
if event_id: if event_id:
markdown_content += f"**Event ID:** {event_id}\n" markdown_content += f"**Event ID:** {event_id}\n"
# Add timing information # Add timing information
markdown_content += f"**Start:** {start_formatted}\n" markdown_content += f"**Start:** {start_formatted}\n"
markdown_content += f"**End:** {end_formatted}\n" markdown_content += f"**End:** {end_formatted}\n"
if timezone: if timezone:
markdown_content += f"**Timezone:** {timezone}\n" markdown_content += f"**Timezone:** {timezone}\n"
markdown_content += "\n" markdown_content += "\n"
# Add location information # Add location information
if location_name or address: if location_name or address:
markdown_content += "## Location\n\n" markdown_content += "## Location\n\n"
@ -317,45 +329,45 @@ class LumaConnector:
if address: if address:
markdown_content += f"**Address:** {address}\n" markdown_content += f"**Address:** {address}\n"
markdown_content += "\n" markdown_content += "\n"
# Add online meeting info # Add online meeting info
if meeting_url: if meeting_url:
markdown_content += f"**Meeting URL:** {meeting_url}\n\n" markdown_content += f"**Meeting URL:** {meeting_url}\n\n"
# Add description if available # Add description if available
if description: if description:
markdown_content += f"## Description\n\n{description}\n\n" markdown_content += f"## Description\n\n{description}\n\n"
# Add event details # Add event details
markdown_content += "## Event Details\n\n" markdown_content += "## Event Details\n\n"
if url: if url:
markdown_content += f"- **Event URL:** {url}\n" markdown_content += f"- **Event URL:** {url}\n"
if visibility: if visibility:
markdown_content += f"- **Visibility:** {visibility}\n" markdown_content += f"- **Visibility:** {visibility}\n"
# Add guest information if available # Add guest information if available
if "guests" in event: if "guests" in event:
guests = event["guests"] guests = event["guests"]
markdown_content += f"\n## Guests ({len(guests)})\n\n" markdown_content += f"\n## Guests ({len(guests)})\n\n"
for guest in guests[:10]: # Show first 10 guests for guest in guests[:10]: # Show first 10 guests
guest_data = guest.get("guest", {}) guest_data = guest.get("guest", {})
name = guest_data.get("name", "Unknown") name = guest_data.get("name", "Unknown")
email = guest_data.get("email", "") email = guest_data.get("email", "")
status = guest.get("registration_status", "unknown") status = guest.get("registration_status", "unknown")
markdown_content += f"- **{name}**" markdown_content += f"- **{name}**"
if email: if email:
markdown_content += f" ({email})" markdown_content += f" ({email})"
markdown_content += f" - Status: {status}\n" markdown_content += f" - Status: {status}\n"
if len(guests) > 10: if len(guests) > 10:
markdown_content += f"- ... and {len(guests) - 10} more guests\n" markdown_content += f"- ... and {len(guests) - 10} more guests\n"
markdown_content += "\n" markdown_content += "\n"
return markdown_content return markdown_content
@staticmethod @staticmethod

View file

@ -4,7 +4,6 @@ from .airtable_add_connector_route import (
router as airtable_add_connector_router, router as airtable_add_connector_router,
) )
from .chats_routes import router as chats_router from .chats_routes import router as chats_router
from .luma_add_connector_route import router as luma_add_connector_router
from .documents_routes import router as documents_router from .documents_routes import router as documents_router
from .google_calendar_add_connector_route import ( from .google_calendar_add_connector_route import (
router as google_calendar_add_connector_router, router as google_calendar_add_connector_router,
@ -14,6 +13,7 @@ from .google_gmail_add_connector_route import (
) )
from .llm_config_routes import router as llm_config_router from .llm_config_routes import router as llm_config_router
from .logs_routes import router as logs_router from .logs_routes import router as logs_router
from .luma_add_connector_route import router as luma_add_connector_router
from .podcasts_routes import router as podcasts_router from .podcasts_routes import router as podcasts_router
from .search_source_connectors_routes import router as search_source_connectors_router from .search_source_connectors_routes import router as search_source_connectors_router
from .search_spaces_routes import router as search_spaces_router from .search_spaces_routes import router as search_spaces_router

View file

@ -1,5 +1,4 @@
import logging import logging
from uuid import UUID
from fastapi import APIRouter, Depends, HTTPException from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
@ -22,7 +21,7 @@ router = APIRouter()
class AddLumaConnectorRequest(BaseModel): class AddLumaConnectorRequest(BaseModel):
"""Request model for adding a Luma connector.""" """Request model for adding a Luma connector."""
api_key: str = Field(..., description="Luma API key") api_key: str = Field(..., description="Luma API key")
space_id: int = Field(..., description="Search space ID") space_id: int = Field(..., description="Search space ID")
@ -35,15 +34,15 @@ async def add_luma_connector(
): ):
""" """
Add a new Luma connector for the authenticated user. Add a new Luma connector for the authenticated user.
Args: Args:
request: The request containing Luma API key and space_id request: The request containing Luma API key and space_id
user: Current authenticated user user: Current authenticated user
session: Database session session: Database session
Returns: Returns:
Success message and connector details Success message and connector details
Raises: Raises:
HTTPException: If connector already exists or validation fails HTTPException: If connector already exists or validation fails
""" """
@ -52,26 +51,27 @@ async def add_luma_connector(
result = await session.execute( result = await session.execute(
select(SearchSourceConnector).filter( select(SearchSourceConnector).filter(
SearchSourceConnector.user_id == user.id, SearchSourceConnector.user_id == user.id,
SearchSourceConnector.connector_type == SearchSourceConnectorType.LUMA_CONNECTOR, SearchSourceConnector.connector_type
== SearchSourceConnectorType.LUMA_CONNECTOR,
) )
) )
existing_connector = result.scalars().first() existing_connector = result.scalars().first()
if existing_connector: if existing_connector:
# Update existing connector with new API key # Update existing connector with new API key
existing_connector.config = {"api_key": request.api_key} existing_connector.config = {"api_key": request.api_key}
existing_connector.is_indexable = True existing_connector.is_indexable = True
await session.commit() await session.commit()
await session.refresh(existing_connector) await session.refresh(existing_connector)
logger.info(f"Updated existing Luma connector for user {user.id}") logger.info(f"Updated existing Luma connector for user {user.id}")
return { return {
"message": "Luma connector updated successfully", "message": "Luma connector updated successfully",
"connector_id": existing_connector.id, "connector_id": existing_connector.id,
"connector_type": "LUMA_CONNECTOR", "connector_type": "LUMA_CONNECTOR",
} }
# Create new Luma connector # Create new Luma connector
db_connector = SearchSourceConnector( db_connector = SearchSourceConnector(
name="Luma Event Connector", name="Luma Event Connector",
@ -80,21 +80,21 @@ async def add_luma_connector(
user_id=user.id, user_id=user.id,
is_indexable=True, is_indexable=True,
) )
session.add(db_connector) session.add(db_connector)
await session.commit() await session.commit()
await session.refresh(db_connector) await session.refresh(db_connector)
logger.info( logger.info(
f"Successfully created Luma connector for user {user.id} with ID {db_connector.id}" f"Successfully created Luma connector for user {user.id} with ID {db_connector.id}"
) )
return { return {
"message": "Luma connector added successfully", "message": "Luma connector added successfully",
"connector_id": db_connector.id, "connector_id": db_connector.id,
"connector_type": "LUMA_CONNECTOR", "connector_type": "LUMA_CONNECTOR",
} }
except IntegrityError as e: except IntegrityError as e:
await session.rollback() await session.rollback()
logger.error(f"Database integrity error: {e!s}") logger.error(f"Database integrity error: {e!s}")
@ -118,14 +118,14 @@ async def delete_luma_connector(
): ):
""" """
Delete the Luma connector for the authenticated user. Delete the Luma connector for the authenticated user.
Args: Args:
user: Current authenticated user user: Current authenticated user
session: Database session session: Database session
Returns: Returns:
Success message Success message
Raises: Raises:
HTTPException: If connector doesn't exist HTTPException: If connector doesn't exist
""" """
@ -133,24 +133,25 @@ async def delete_luma_connector(
result = await session.execute( result = await session.execute(
select(SearchSourceConnector).filter( select(SearchSourceConnector).filter(
SearchSourceConnector.user_id == user.id, SearchSourceConnector.user_id == user.id,
SearchSourceConnector.connector_type == SearchSourceConnectorType.LUMA_CONNECTOR, SearchSourceConnector.connector_type
== SearchSourceConnectorType.LUMA_CONNECTOR,
) )
) )
connector = result.scalars().first() connector = result.scalars().first()
if not connector: if not connector:
raise HTTPException( raise HTTPException(
status_code=404, status_code=404,
detail="Luma connector not found for this user.", detail="Luma connector not found for this user.",
) )
await session.delete(connector) await session.delete(connector)
await session.commit() await session.commit()
logger.info(f"Successfully deleted Luma connector for user {user.id}") logger.info(f"Successfully deleted Luma connector for user {user.id}")
return {"message": "Luma connector deleted successfully"} return {"message": "Luma connector deleted successfully"}
except HTTPException: except HTTPException:
raise raise
except Exception as e: except Exception as e:
@ -169,14 +170,14 @@ async def test_luma_connector(
): ):
""" """
Test the Luma connector for the authenticated user. Test the Luma connector for the authenticated user.
Args: Args:
user: Current authenticated user user: Current authenticated user
session: Database session session: Database session
Returns: Returns:
Test results including user info and event count Test results including user info and event count
Raises: Raises:
HTTPException: If connector doesn't exist or test fails HTTPException: If connector doesn't exist or test fails
""" """
@ -185,20 +186,21 @@ async def test_luma_connector(
result = await session.execute( result = await session.execute(
select(SearchSourceConnector).filter( select(SearchSourceConnector).filter(
SearchSourceConnector.user_id == user.id, SearchSourceConnector.user_id == user.id,
SearchSourceConnector.connector_type == SearchSourceConnectorType.LUMA_CONNECTOR, SearchSourceConnector.connector_type
== SearchSourceConnectorType.LUMA_CONNECTOR,
) )
) )
connector = result.scalars().first() connector = result.scalars().first()
if not connector: if not connector:
raise HTTPException( raise HTTPException(
status_code=404, status_code=404,
detail="Luma connector not found. Please add a connector first.", detail="Luma connector not found. Please add a connector first.",
) )
# Import LumaConnector # Import LumaConnector
from app.connectors.luma_connector import LumaConnector from app.connectors.luma_connector import LumaConnector
# Initialize the connector # Initialize the connector
api_key = connector.config.get("api_key") api_key = connector.config.get("api_key")
if not api_key: if not api_key:
@ -206,9 +208,9 @@ async def test_luma_connector(
status_code=400, status_code=400,
detail="Invalid connector configuration: API key missing.", detail="Invalid connector configuration: API key missing.",
) )
luma = LumaConnector(api_key=api_key) luma = LumaConnector(api_key=api_key)
# Test the connection by fetching user info # Test the connection by fetching user info
user_info, error = luma.get_user_info() user_info, error = luma.get_user_info()
if error: if error:
@ -216,10 +218,10 @@ async def test_luma_connector(
status_code=400, status_code=400,
detail=f"Failed to connect to Luma: {error}", detail=f"Failed to connect to Luma: {error}",
) )
# Try to fetch events # Try to fetch events
events, events_error = luma.get_all_events(limit=10) events, events_error = luma.get_all_events(limit=10)
return { return {
"message": "Luma connector is working correctly", "message": "Luma connector is working correctly",
"user_info": { "user_info": {
@ -229,7 +231,7 @@ async def test_luma_connector(
"event_count": len(events) if not events_error else 0, "event_count": len(events) if not events_error else 0,
"events_error": events_error, "events_error": events_error,
} }
except HTTPException: except HTTPException:
raise raise
except Exception as e: except Exception as e:

View file

@ -45,9 +45,9 @@ from app.tasks.connector_indexers import (
index_google_gmail_messages, index_google_gmail_messages,
index_jira_issues, index_jira_issues,
index_linear_issues, index_linear_issues,
index_luma_events,
index_notion_pages, index_notion_pages,
index_slack_messages, index_slack_messages,
index_luma_events
) )
from app.users import current_active_user from app.users import current_active_user
from app.utils.check_ownership import check_ownership from app.utils.check_ownership import check_ownership
@ -1280,6 +1280,7 @@ async def run_google_gmail_indexing(
) )
# Optionally update status in DB to indicate failure # Optionally update status in DB to indicate failure
# Add new helper functions for luma indexing # Add new helper functions for luma indexing
async def run_luma_indexing_with_new_session( async def run_luma_indexing_with_new_session(
connector_id: int, connector_id: int,
@ -1297,6 +1298,7 @@ async def run_luma_indexing_with_new_session(
session, connector_id, search_space_id, user_id, start_date, end_date session, connector_id, search_space_id, user_id, start_date, end_date
) )
async def run_luma_indexing( async def run_luma_indexing(
session: AsyncSession, session: AsyncSession,
connector_id: int, connector_id: int,
@ -1338,4 +1340,4 @@ async def run_luma_indexing(
f"Luma indexing failed or no documents processed: {error_or_warning}" f"Luma indexing failed or no documents processed: {error_or_warning}"
) )
except Exception as e: except Exception as e:
logger.error(f"Error in background Luma indexing task: {e!s}") logger.error(f"Error in background Luma indexing task: {e!s}")

View file

@ -1951,14 +1951,15 @@ class ConnectorService:
info_parts.append(f"Venue: {location_name}") info_parts.append(f"Venue: {location_name}")
elif location_address: elif location_address:
info_parts.append(f"Location: {location_address}") info_parts.append(f"Location: {location_address}")
if meeting_url: if meeting_url:
info_parts.append("Online Event") info_parts.append("Online Event")
if end_time: if end_time:
try: try:
if "T" in end_time: if "T" in end_time:
from datetime import datetime from datetime import datetime
end_dt = datetime.fromisoformat( end_dt = datetime.fromisoformat(
end_time.replace("Z", "+00:00") end_time.replace("Z", "+00:00")
) )
@ -1968,10 +1969,10 @@ class ConnectorService:
info_parts.append(f"Ends: {end_time}") info_parts.append(f"Ends: {end_time}")
except Exception: except Exception:
info_parts.append(f"Ends: {end_time}") info_parts.append(f"Ends: {end_time}")
if timezone: if timezone:
info_parts.append(f"TZ: {timezone}") info_parts.append(f"TZ: {timezone}")
if visibility: if visibility:
info_parts.append(f"Visibility: {visibility.title()}") info_parts.append(f"Visibility: {visibility.title()}")

View file

@ -31,10 +31,10 @@ from .github_indexer import index_github_repos
from .google_calendar_indexer import index_google_calendar_events from .google_calendar_indexer import index_google_calendar_events
from .google_gmail_indexer import index_google_gmail_messages from .google_gmail_indexer import index_google_gmail_messages
from .jira_indexer import index_jira_issues from .jira_indexer import index_jira_issues
from .luma_indexer import index_luma_events
# Issue tracking and project management # Issue tracking and project management
from .linear_indexer import index_linear_issues from .linear_indexer import index_linear_issues
from .luma_indexer import index_luma_events
# Documentation and knowledge management # Documentation and knowledge management
from .notion_indexer import index_notion_pages from .notion_indexer import index_notion_pages

View file

@ -84,11 +84,14 @@ async def index_luma_events(
"Connector not found", "Connector not found",
{"error_type": "ConnectorNotFound"}, {"error_type": "ConnectorNotFound"},
) )
return 0, f"Connector with ID {connector_id} not found or is not a Luma connector" return (
0,
f"Connector with ID {connector_id} not found or is not a Luma connector",
)
# Get the Luma API key from the connector config # Get the Luma API key from the connector config
api_key = connector.config.get("LUMA_API_KEY") api_key = connector.config.get("LUMA_API_KEY")
if not api_key: if not api_key:
await task_logger.log_task_failure( await task_logger.log_task_failure(
log_entry, log_entry,
@ -97,7 +100,7 @@ async def index_luma_events(
{"error_type": "MissingCredentials"}, {"error_type": "MissingCredentials"},
) )
return 0, "Luma API key not found in connector config" return 0, "Luma API key not found in connector config"
logger.info(f"Starting Luma indexing for connector {connector_id}") logger.info(f"Starting Luma indexing for connector {connector_id}")
# Initialize Luma client # Initialize Luma client
@ -107,9 +110,7 @@ async def index_luma_events(
{"stage": "client_initialization"}, {"stage": "client_initialization"},
) )
luma_client = LumaConnector( luma_client = LumaConnector(api_key=api_key)
api_key=api_key
)
# Calculate date range # Calculate date range
if start_date is None or end_date is None: if start_date is None or end_date is None:
@ -167,9 +168,7 @@ async def index_luma_events(
# Get events within date range from Luma # Get events within date range from Luma
try: try:
events, error = luma_client.get_events_by_date_range( events, error = luma_client.get_events_by_date_range(
start_date_str, start_date_str, end_date_str, include_guests=False
end_date_str,
include_guests=False
) )
if error: if error:
@ -221,7 +220,7 @@ async def index_luma_events(
event_id = event.get("api_id") or event_data.get("id") event_id = event.get("api_id") or event_data.get("id")
event_name = event_data.get("name", "No Title") event_name = event_data.get("name", "No Title")
event_url = event_data.get("url", "") event_url = event_data.get("url", "")
if not event_id: if not event_id:
logger.warning(f"Skipping event with missing ID: {event_name}") logger.warning(f"Skipping event with missing ID: {event_name}")
skipped_events.append(f"{event_name} (missing ID)") skipped_events.append(f"{event_name} (missing ID)")
@ -240,19 +239,21 @@ async def index_luma_events(
start_at = event_data.get("start_at", "") start_at = event_data.get("start_at", "")
end_at = event_data.get("end_at", "") end_at = event_data.get("end_at", "")
timezone = event_data.get("timezone", "") timezone = event_data.get("timezone", "")
# Location info from geo_info # Location info from geo_info
geo_info = event_data.get("geo_info", {}) geo_info = event_data.get("geo_info", {})
location = geo_info.get("address", "") location = geo_info.get("address", "")
city = geo_info.get("city", "") city = geo_info.get("city", "")
# Host info # Host info
hosts = event_data.get("hosts", []) hosts = event_data.get("hosts", [])
host_names = ", ".join([host.get("name", "") for host in hosts if host.get("name")]) host_names = ", ".join(
[host.get("name", "") for host in hosts if host.get("name")]
)
description = event_data.get("description", "") description = event_data.get("description", "")
cover_url = event_data.get("cover_url", "") cover_url = event_data.get("cover_url", "")
content_hash = generate_content_hash(event_markdown, search_space_id) content_hash = generate_content_hash(event_markdown, search_space_id)
# Duplicate check via simple query using helper in base # Duplicate check via simple query using helper in base
@ -311,11 +312,11 @@ async def index_luma_events(
if len(description) > 300: if len(description) > 300:
desc_preview += "..." desc_preview += "..."
summary_content += f"Description: {desc_preview}\n" summary_content += f"Description: {desc_preview}\n"
summary_embedding = config.embedding_model_instance.embed( summary_embedding = config.embedding_model_instance.embed(
summary_content summary_content
) )
chunks = await create_document_chunks(event_markdown) chunks = await create_document_chunks(event_markdown)
document = Document( document = Document(
@ -397,4 +398,4 @@ async def index_luma_events(
{"error_type": type(e).__name__}, {"error_type": type(e).__name__},
) )
logger.error(f"Failed to index Luma events: {e!s}", exc_info=True) logger.error(f"Failed to index Luma events: {e!s}", exc_info=True)
return 0, f"Failed to index Luma events: {e!s}" return 0, f"Failed to index Luma events: {e!s}"

View file

@ -53,7 +53,7 @@ const getConnectorTypeDisplay = (type: string): string => {
GOOGLE_CALENDAR_CONNECTOR: "Google Calendar Connector", GOOGLE_CALENDAR_CONNECTOR: "Google Calendar Connector",
GOOGLE_GMAIL_CONNECTOR: "Google Gmail Connector", GOOGLE_GMAIL_CONNECTOR: "Google Gmail Connector",
AIRTABLE_CONNECTOR: "Airtable Connector", AIRTABLE_CONNECTOR: "Airtable Connector",
LUMA_CONNECTOR: "Luma Connector" LUMA_CONNECTOR: "Luma Connector",
// Add other connector types here as needed // Add other connector types here as needed
}; };
return typeMap[type] || type; return typeMap[type] || type;
@ -72,7 +72,7 @@ const getApiKeyFieldName = (connectorType: string): string => {
GITHUB_CONNECTOR: "GITHUB_PAT", GITHUB_CONNECTOR: "GITHUB_PAT",
DISCORD_CONNECTOR: "DISCORD_BOT_TOKEN", DISCORD_CONNECTOR: "DISCORD_BOT_TOKEN",
LINKUP_API: "LINKUP_API_KEY", LINKUP_API: "LINKUP_API_KEY",
LUMA_CONNECTOR: "LUMA_API_KEY" LUMA_CONNECTOR: "LUMA_API_KEY",
}; };
return fieldMap[connectorType] || ""; return fieldMap[connectorType] || "";
}; };

View file

@ -54,7 +54,7 @@ export default function LumaConnectorPage() {
const searchSpaceId = params.search_space_id as string; const searchSpaceId = params.search_space_id as string;
const [isSubmitting, setIsSubmitting] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false);
const [doesConnectorExist, setDoesConnectorExist] = useState(false); const [doesConnectorExist, setDoesConnectorExist] = useState(false);
const { fetchConnectors, createConnector } = useSearchSourceConnectors(); const { fetchConnectors, createConnector } = useSearchSourceConnectors();
// Initialize the form // Initialize the form
@ -69,8 +69,7 @@ export default function LumaConnectorPage() {
useEffect(() => { useEffect(() => {
fetchConnectors().then((data) => { fetchConnectors().then((data) => {
const connector = data.find( const connector = data.find(
(c: SearchSourceConnector) => (c: SearchSourceConnector) => c.connector_type === EnumConnectorName.LUMA_CONNECTOR
c.connector_type === EnumConnectorName.LUMA_CONNECTOR
); );
if (connector) { if (connector) {
setDoesConnectorExist(true); setDoesConnectorExist(true);
@ -86,14 +85,14 @@ export default function LumaConnectorPage() {
name: values.name, name: values.name,
connector_type: EnumConnectorName.LUMA_CONNECTOR, connector_type: EnumConnectorName.LUMA_CONNECTOR,
config: { config: {
LUMA_API_KEY: values.api_key LUMA_API_KEY: values.api_key,
}, },
is_indexable: true, is_indexable: true,
last_indexed_at: null, last_indexed_at: null,
}); });
toast.success("Luma connector created successfully!"); toast.success("Luma connector created successfully!");
// Navigate back to connectors page // Navigate back to connectors page
router.push(`/dashboard/${searchSpaceId}/connectors`); router.push(`/dashboard/${searchSpaceId}/connectors`);
} catch (error) { } catch (error) {
@ -126,9 +125,7 @@ export default function LumaConnectorPage() {
</div> </div>
<div> <div>
<h1 className="text-3xl font-bold tracking-tight">Connect Luma</h1> <h1 className="text-3xl font-bold tracking-tight">Connect Luma</h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">Connect your Luma account to search events.</p>
Connect your Luma account to search events.
</p>
</div> </div>
</div> </div>
</div> </div>
@ -170,11 +167,7 @@ export default function LumaConnectorPage() {
<FormItem> <FormItem>
<FormLabel>API Key</FormLabel> <FormLabel>API Key</FormLabel>
<FormControl> <FormControl>
<Input <Input type="password" placeholder="Enter your Luma API key" {...field} />
type="password"
placeholder="Enter your Luma API key"
{...field}
/>
</FormControl> </FormControl>
<FormDescription> <FormDescription>
Your API key will be encrypted and stored securely. Your API key will be encrypted and stored securely.

View file

@ -146,7 +146,7 @@ const connectorCategories: ConnectorCategory[] = [
description: "Connect to Luma to search events", description: "Connect to Luma to search events",
icon: getConnectorIcon(EnumConnectorName.LUMA_CONNECTOR, "h-6 w-6"), icon: getConnectorIcon(EnumConnectorName.LUMA_CONNECTOR, "h-6 w-6"),
status: "available", status: "available",
} },
], ],
}, },
{ {

View file

@ -43,6 +43,6 @@ export const editConnectorSchema = z.object({
GOOGLE_CALENDAR_CLIENT_SECRET: z.string().optional(), GOOGLE_CALENDAR_CLIENT_SECRET: z.string().optional(),
GOOGLE_CALENDAR_REFRESH_TOKEN: z.string().optional(), GOOGLE_CALENDAR_REFRESH_TOKEN: z.string().optional(),
GOOGLE_CALENDAR_CALENDAR_IDS: z.string().optional(), GOOGLE_CALENDAR_CALENDAR_IDS: z.string().optional(),
LUMA_API_KEY: z.string().optional() LUMA_API_KEY: z.string().optional(),
}); });
export type EditConnectorFormValues = z.infer<typeof editConnectorSchema>; export type EditConnectorFormValues = z.infer<typeof editConnectorSchema>;

View file

@ -13,5 +13,5 @@ export enum EnumConnectorName {
GOOGLE_CALENDAR_CONNECTOR = "GOOGLE_CALENDAR_CONNECTOR", GOOGLE_CALENDAR_CONNECTOR = "GOOGLE_CALENDAR_CONNECTOR",
GOOGLE_GMAIL_CONNECTOR = "GOOGLE_GMAIL_CONNECTOR", GOOGLE_GMAIL_CONNECTOR = "GOOGLE_GMAIL_CONNECTOR",
AIRTABLE_CONNECTOR = "AIRTABLE_CONNECTOR", AIRTABLE_CONNECTOR = "AIRTABLE_CONNECTOR",
LUMA_CONNECTOR = "LUMA_CONNECTOR" LUMA_CONNECTOR = "LUMA_CONNECTOR",
} }

View file

@ -10,10 +10,10 @@ import {
IconLayoutKanban, IconLayoutKanban,
IconLinkPlus, IconLinkPlus,
IconMail, IconMail,
IconSparkles,
IconTable, IconTable,
IconTicket, IconTicket,
IconWorldWww, IconWorldWww,
IconSparkles,
} from "@tabler/icons-react"; } from "@tabler/icons-react";
import { File, Globe, Link, Microscope, Search, Sparkles, Telescope, Webhook } from "lucide-react"; import { File, Globe, Link, Microscope, Search, Sparkles, Telescope, Webhook } from "lucide-react";
import { EnumConnectorName } from "./connector"; import { EnumConnectorName } from "./connector";

View file

@ -52,7 +52,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
JIRA_BASE_URL: "", JIRA_BASE_URL: "",
JIRA_EMAIL: "", JIRA_EMAIL: "",
JIRA_API_TOKEN: "", JIRA_API_TOKEN: "",
LUMA_API_KEY: "" LUMA_API_KEY: "",
}, },
}); });
@ -79,7 +79,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
JIRA_BASE_URL: config.JIRA_BASE_URL || "", JIRA_BASE_URL: config.JIRA_BASE_URL || "",
JIRA_EMAIL: config.JIRA_EMAIL || "", JIRA_EMAIL: config.JIRA_EMAIL || "",
JIRA_API_TOKEN: config.JIRA_API_TOKEN || "", JIRA_API_TOKEN: config.JIRA_API_TOKEN || "",
LUMA_API_KEY: config.LUMA_API_KEY || "" LUMA_API_KEY: config.LUMA_API_KEY || "",
}); });
if (currentConnector.connector_type === "GITHUB_CONNECTOR") { if (currentConnector.connector_type === "GITHUB_CONNECTOR") {
const savedRepos = config.repo_full_names || []; const savedRepos = config.repo_full_names || [];
@ -312,7 +312,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
setIsSaving(false); setIsSaving(false);
return; return;
} }
newConfig = { LUMA_API_KEY: formData.LUMA_API_KEY}; newConfig = { LUMA_API_KEY: formData.LUMA_API_KEY };
} }
break; break;
} }

View file

@ -15,7 +15,7 @@ export const getConnectorTypeDisplay = (type: string): string => {
GOOGLE_CALENDAR_CONNECTOR: "Google Calendar", GOOGLE_CALENDAR_CONNECTOR: "Google Calendar",
GOOGLE_GMAIL_CONNECTOR: "Google Gmail", GOOGLE_GMAIL_CONNECTOR: "Google Gmail",
AIRTABLE_CONNECTOR: "Airtable", AIRTABLE_CONNECTOR: "Airtable",
LUMA_CONNECTOR: "Luma" LUMA_CONNECTOR: "Luma",
}; };
return typeMap[type] || type; return typeMap[type] || type;
}; };