- Adding Prometheus and grafana services in development
- Adding Prometheus metrics to the business events - Ensure asynchronous behaviour of crewai specialists. - Adapt Business events to working in mixed synchronous / asynchronous contexts - Extend business events with specialist information - Started adding a grafana dashboard (TBC)
This commit is contained in:
@@ -226,26 +226,39 @@ def execute_specialist(self, tenant_id: int, specialist_id: int, arguments: Dict
|
||||
task_id = self.request.id
|
||||
ept = ExecutionProgressTracker()
|
||||
ept.send_update(task_id, "EveAI Specialist Started", {})
|
||||
with BusinessEvent("Execute Specialist", tenant_id=tenant_id, chat_session_id=session_id) as event:
|
||||
|
||||
# Prepare context
|
||||
try:
|
||||
# Retrieve the tenant
|
||||
tenant = Tenant.query.get(tenant_id)
|
||||
if not tenant:
|
||||
raise Exception(f'Tenant {tenant_id} not found.')
|
||||
|
||||
# Switch to correct database schema
|
||||
Database(str(tenant_id)).switch_schema()
|
||||
|
||||
# Get specialist from database
|
||||
specialist = Specialist.query.get_or_404(specialist_id)
|
||||
except Exception as e:
|
||||
ept.send_update(task_id, "EveAI Specialist Error", {'Error': str(e)})
|
||||
current_app.logger.error(f'execute_specialist: Error executing specialist: {e}')
|
||||
raise
|
||||
|
||||
with BusinessEvent("Execute Specialist",
|
||||
tenant_id=tenant_id,
|
||||
chat_session_id=session_id,
|
||||
specialist_id=specialist_id,
|
||||
specialist_type=specialist.type,
|
||||
specialist_type_version=specialist.type_version) as event:
|
||||
current_app.logger.info(
|
||||
f'execute_specialist: Processing request for tenant {tenant_id} using specialist {specialist_id}')
|
||||
|
||||
try:
|
||||
# Retrieve the tenant
|
||||
tenant = Tenant.query.get(tenant_id)
|
||||
if not tenant:
|
||||
raise Exception(f'Tenant {tenant_id} not found.')
|
||||
|
||||
# Switch to correct database schema
|
||||
Database(tenant_id).switch_schema()
|
||||
|
||||
# Ensure we have a session
|
||||
cached_session = cache_manager.chat_session_cache.get_cached_session(
|
||||
session_id,
|
||||
create_params={'timezone': user_timezone}
|
||||
)
|
||||
# Get specialist from database
|
||||
specialist = Specialist.query.get_or_404(specialist_id)
|
||||
|
||||
# Prepare complete arguments
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user