- Build of the Chat Client using Vue.js
- Accompanying css - Views to serve the Chat Client - first test version of the TRACIE_SELECTION_SPECIALIST - ESS Implemented.
This commit is contained in:
@@ -2,7 +2,7 @@ import asyncio
|
||||
import json
|
||||
from os import wait
|
||||
from typing import Optional, List
|
||||
|
||||
from time import sleep
|
||||
from crewai.flow.flow import start, listen, and_
|
||||
from flask import current_app
|
||||
from pydantic import BaseModel, Field
|
||||
@@ -22,7 +22,7 @@ from common.services.interaction.specialist_services import SpecialistServices
|
||||
class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
"""
|
||||
type: TRAICIE_SELECTION_SPECIALIST
|
||||
type_version: 1.0
|
||||
type_version: 1.1
|
||||
Traicie Selection Specialist Executor class
|
||||
"""
|
||||
|
||||
@@ -40,7 +40,7 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
|
||||
@property
|
||||
def type_version(self) -> str:
|
||||
return "1.0"
|
||||
return "1.1"
|
||||
|
||||
def _config_task_agents(self):
|
||||
self._add_task_agent("traicie_get_competencies_task", "traicie_hr_bp_agent")
|
||||
@@ -67,25 +67,34 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
)
|
||||
|
||||
def execute(self, arguments: SpecialistArguments, formatted_context, citations) -> SpecialistResult:
|
||||
self.log_tuning("Traicie Role Definition Specialist execution started", {})
|
||||
self.log_tuning("Traicie Selection Specialist execution started", {})
|
||||
|
||||
flow_inputs = {
|
||||
"vacancy_text": arguments.vacancy_text,
|
||||
"role_name": arguments.role_name,
|
||||
'role_reference': arguments.role_reference,
|
||||
}
|
||||
# flow_inputs = {
|
||||
# "vacancy_text": arguments.vacancy_text,
|
||||
# "role_name": arguments.role_name,
|
||||
# 'role_reference': arguments.role_reference,
|
||||
# }
|
||||
#
|
||||
# flow_results = self.flow.kickoff(inputs=flow_inputs)
|
||||
#
|
||||
# flow_state = self.flow.state
|
||||
#
|
||||
# results = RoleDefinitionSpecialistResult.create_for_type(self.type, self.type_version)
|
||||
# if flow_state.competencies:
|
||||
# results.competencies = flow_state.competencies
|
||||
|
||||
flow_results = self.flow.kickoff(inputs=flow_inputs)
|
||||
# self.create_selection_specialist(arguments, flow_state.competencies)
|
||||
for i in range(5):
|
||||
sleep(3)
|
||||
self.ept.send_update(self.task_id, "Traicie Selection Specialist Processing", {"name": f"Processing Iteration {i}"})
|
||||
|
||||
flow_state = self.flow.state
|
||||
# flow_results = asyncio.run(self.flow.kickoff_async(inputs=arguments.model_dump()))
|
||||
# flow_state = self.flow.state
|
||||
# results = RoleDefinitionSpecialistResult.create_for_type(self.type, self.type_version)
|
||||
results = SpecialistResult.create_for_type(self.type, self.type_version,
|
||||
answer=f"Antwoord op uw vraag: {arguments.question}")
|
||||
|
||||
results = RoleDefinitionSpecialistResult.create_for_type(self.type, self.type_version)
|
||||
if flow_state.competencies:
|
||||
results.competencies = flow_state.competencies
|
||||
|
||||
self.create_selection_specialist(arguments, flow_state.competencies)
|
||||
|
||||
self.log_tuning(f"Traicie Role Definition Specialist execution ended", {"Results": results.model_dump()})
|
||||
self.log_tuning(f"Traicie Selection Specialist execution ended", {"Results": results.model_dump()})
|
||||
|
||||
return results
|
||||
|
||||
@@ -129,9 +138,7 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
current_app.logger.error(f"Error creating selection specialist: {str(e)}")
|
||||
raise e
|
||||
|
||||
SpecialistServices.initialize_specialist(new_specialist.id, "TRAICIE_SELECTION_SPECIALIST", "1.0")
|
||||
|
||||
|
||||
SpecialistServices.initialize_specialist(new_specialist.id, self.type, self.type_version)
|
||||
|
||||
|
||||
class RoleDefinitionSpecialistInput(BaseModel):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from datetime import datetime as dt, timezone as tz
|
||||
from typing import Dict, Any, Optional
|
||||
import traceback
|
||||
|
||||
from flask import current_app
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
@@ -240,8 +241,9 @@ def execute_specialist(self, tenant_id: int, specialist_id: int, arguments: Dict
|
||||
# Get specialist from database
|
||||
specialist = Specialist.query.get_or_404(specialist_id)
|
||||
except Exception as e:
|
||||
stacktrace = traceback.format_exc()
|
||||
ept.send_update(task_id, "EveAI Specialist Error", {'Error': str(e)})
|
||||
current_app.logger.error(f'execute_specialist: Error executing specialist: {e}')
|
||||
current_app.logger.error(f'execute_specialist: Error executing specialist: {e}\n{stacktrace}')
|
||||
raise
|
||||
|
||||
with BusinessEvent("Execute Specialist",
|
||||
@@ -272,7 +274,8 @@ def execute_specialist(self, tenant_id: int, specialist_id: int, arguments: Dict
|
||||
retriever_args=raw_arguments.get('retriever_arguments', {})
|
||||
)
|
||||
except ValueError as e:
|
||||
current_app.logger.error(f'execute_specialist: Error preparing arguments: {e}')
|
||||
stacktrace = traceback.format_exc()
|
||||
current_app.logger.error(f'execute_specialist: Error preparing arguments: {e}\n{stacktrace}')
|
||||
raise
|
||||
|
||||
# Create new interaction record
|
||||
@@ -289,7 +292,8 @@ def execute_specialist(self, tenant_id: int, specialist_id: int, arguments: Dict
|
||||
event.update_attribute('interaction_id', new_interaction.id)
|
||||
|
||||
except SQLAlchemyError as e:
|
||||
current_app.logger.error(f'execute_specialist: Error creating interaction: {e}')
|
||||
stacktrace = traceback.format_exc()
|
||||
current_app.logger.error(f'execute_specialist: Error creating interaction: {e}\n{stacktrace}')
|
||||
raise
|
||||
|
||||
with current_event.create_span("Specialist invocation"):
|
||||
@@ -314,7 +318,8 @@ def execute_specialist(self, tenant_id: int, specialist_id: int, arguments: Dict
|
||||
db.session.add(new_interaction)
|
||||
db.session.commit()
|
||||
except SQLAlchemyError as e:
|
||||
current_app.logger.error(f'execute_specialist: Error updating interaction: {e}')
|
||||
stacktrace = traceback.format_exc()
|
||||
current_app.logger.error(f'execute_specialist: Error updating interaction: {e}\n{stacktrace}')
|
||||
raise
|
||||
|
||||
# Now that we have a complete interaction with an answer, add it to the cache
|
||||
@@ -330,14 +335,16 @@ def execute_specialist(self, tenant_id: int, specialist_id: int, arguments: Dict
|
||||
return response
|
||||
|
||||
except Exception as e:
|
||||
stacktrace = traceback.format_exc()
|
||||
ept.send_update(task_id, "EveAI Specialist Error", {'Error': str(e)})
|
||||
current_app.logger.error(f'execute_specialist: Error executing specialist: {e}')
|
||||
current_app.logger.error(f'execute_specialist: Error executing specialist: {e}\n{stacktrace}')
|
||||
new_interaction.processing_error = str(e)[:255]
|
||||
try:
|
||||
db.session.add(new_interaction)
|
||||
db.session.commit()
|
||||
except SQLAlchemyError as e:
|
||||
current_app.logger.error(f'execute_specialist: Error updating interaction: {e}')
|
||||
stacktrace = traceback.format_exc()
|
||||
current_app.logger.error(f'execute_specialist: Error updating interaction: {e}\n{stacktrace}')
|
||||
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user