- Introduction of preferred contact time form
- Logging asset usage in TRAICIE_SELECTION_SPECIALIST
This commit is contained in:
2
common/utils/cache/translation_cache.py
vendored
2
common/utils/cache/translation_cache.py
vendored
@@ -121,7 +121,7 @@ class TranslationCacheHandler(CacheHandler[TranslationCache]):
|
|||||||
'prompt_tokens': existing_translation.prompt_tokens,
|
'prompt_tokens': existing_translation.prompt_tokens,
|
||||||
'completion_tokens': existing_translation.completion_tokens,
|
'completion_tokens': existing_translation.completion_tokens,
|
||||||
'time_elapsed': 0,
|
'time_elapsed': 0,
|
||||||
'interaction_type': 'LLM'
|
'interaction_type': 'TRANSLATION'
|
||||||
}
|
}
|
||||||
current_event.log_llm_metrics(metrics)
|
current_event.log_llm_metrics(metrics)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
type: "CONTACT_TIME_PREFERENCES_SIMPLE"
|
||||||
|
version: "1.0.0"
|
||||||
|
name: "Contact Time Preferences"
|
||||||
|
icon: "calendar_month"
|
||||||
|
fields:
|
||||||
|
early:
|
||||||
|
name: "Early in the morning"
|
||||||
|
description: "Contact me early in the morning"
|
||||||
|
type: "boolean"
|
||||||
|
required: false
|
||||||
|
# It is possible to also add a field 'context'. It allows you to provide an elaborate piece of information.
|
||||||
|
late_morning:
|
||||||
|
name: "During the morning"
|
||||||
|
description: "Contact me during the morning"
|
||||||
|
type: "boolean"
|
||||||
|
required: false
|
||||||
|
afternoon:
|
||||||
|
name: "In the afternoon"
|
||||||
|
description: "Contact me in the afternoon"
|
||||||
|
type: "boolean"
|
||||||
|
required: false
|
||||||
|
evening:
|
||||||
|
name: "In the evening"
|
||||||
|
description: "Contact me in the evening"
|
||||||
|
type: "boolean"
|
||||||
|
required: false
|
||||||
|
other:
|
||||||
|
name: "Other"
|
||||||
|
description: "Specify your preferred contact moment"
|
||||||
|
type: "string"
|
||||||
|
required: false
|
||||||
|
metadata:
|
||||||
|
author: "Josako"
|
||||||
|
date_added: "2025-07-22"
|
||||||
|
changes: "Initial Version"
|
||||||
|
description: "Simple Contact Time Preferences Form"
|
||||||
@@ -8,4 +8,8 @@ SPECIALIST_FORM_TYPES = {
|
|||||||
"name": "Professional Contact Form",
|
"name": "Professional Contact Form",
|
||||||
"description": "A form for entering your professional contact details",
|
"description": "A form for entering your professional contact details",
|
||||||
},
|
},
|
||||||
|
"CONTACT_TIME_PREFERENCES_SIMPLE": {
|
||||||
|
"name": "Contact Time Preferences Form",
|
||||||
|
"description": "A form for entering contact time preferences",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ from common.models.interaction import EveAIAsset
|
|||||||
from common.models.user import Tenant
|
from common.models.user import Tenant
|
||||||
from common.services.utils.human_answer_services import HumanAnswerServices
|
from common.services.utils.human_answer_services import HumanAnswerServices
|
||||||
from common.services.utils.translation_services import TranslationServices
|
from common.services.utils.translation_services import TranslationServices
|
||||||
|
from common.utils.business_event_context import current_event
|
||||||
from common.utils.eveai_exceptions import EveAISpecialistExecutionError
|
from common.utils.eveai_exceptions import EveAISpecialistExecutionError
|
||||||
from eveai_chat_workers.definitions.language_level.language_level_v1_0 import LANGUAGE_LEVEL
|
from eveai_chat_workers.definitions.language_level.language_level_v1_0 import LANGUAGE_LEVEL
|
||||||
from eveai_chat_workers.definitions.tone_of_voice.tone_of_voice_v1_0 import TONE_OF_VOICE
|
from eveai_chat_workers.definitions.tone_of_voice.tone_of_voice_v1_0 import TONE_OF_VOICE
|
||||||
@@ -21,7 +22,7 @@ from eveai_chat_workers.specialists.crewai_base_classes import EveAICrewAICrew,
|
|||||||
from eveai_chat_workers.specialists.crewai_base_specialist import CrewAIBaseSpecialistExecutor
|
from eveai_chat_workers.specialists.crewai_base_specialist import CrewAIBaseSpecialistExecutor
|
||||||
from eveai_chat_workers.specialists.specialist_typing import SpecialistResult, SpecialistArguments
|
from eveai_chat_workers.specialists.specialist_typing import SpecialistResult, SpecialistArguments
|
||||||
|
|
||||||
INITIALISATION_MESSAGE = "Let's start the selection process by asking you a few important questions."
|
INITIALISATION_MESSAGE = "Thank you for showing your interest! Let's start the selection process by asking you a few important questions."
|
||||||
START_SELECTION_QUESTION = "Do you want to start the selection procedure?"
|
START_SELECTION_QUESTION = "Do you want to start the selection procedure?"
|
||||||
INSUFFICIENT_INFORMATION_MESSAGE = (
|
INSUFFICIENT_INFORMATION_MESSAGE = (
|
||||||
"We do not have the necessary information to provide you with the requested answers. "
|
"We do not have the necessary information to provide you with the requested answers. "
|
||||||
@@ -163,8 +164,6 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
|||||||
def execute_start_selection_procedure_state(self, arguments: SpecialistArguments, formatted_context, citations,
|
def execute_start_selection_procedure_state(self, arguments: SpecialistArguments, formatted_context, citations,
|
||||||
start_message=None) -> SpecialistResult:
|
start_message=None) -> SpecialistResult:
|
||||||
|
|
||||||
answer = ""
|
|
||||||
if start_message:
|
|
||||||
initialisation_message = TranslationServices.translate(self.tenant_id, INITIALISATION_MESSAGE,
|
initialisation_message = TranslationServices.translate(self.tenant_id, INITIALISATION_MESSAGE,
|
||||||
arguments.language)
|
arguments.language)
|
||||||
answer = f"{start_message}\n\n{initialisation_message}"
|
answer = f"{start_message}\n\n{initialisation_message}"
|
||||||
@@ -440,6 +439,21 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
|||||||
raise EveAISpecialistExecutionError(self.tenant_id, self.specialist_id, self.session_id,
|
raise EveAISpecialistExecutionError(self.tenant_id, self.specialist_id, self.session_id,
|
||||||
"No KO criteria questions found")
|
"No KO criteria questions found")
|
||||||
|
|
||||||
|
# Register Asset Usage
|
||||||
|
prompt_tokens = ko_questions_asset.prompt_tokens
|
||||||
|
completion_tokens = ko_questions_asset.completion_tokens
|
||||||
|
total_tokens = prompt_tokens + completion_tokens
|
||||||
|
|
||||||
|
metrics = {
|
||||||
|
'total_tokens': total_tokens,
|
||||||
|
'prompt_tokens': prompt_tokens,
|
||||||
|
'completion_tokens': completion_tokens,
|
||||||
|
'time_elapsed': 0,
|
||||||
|
'interaction_type': 'ASSET',
|
||||||
|
}
|
||||||
|
|
||||||
|
current_event.log_llm_metrics(metrics)
|
||||||
|
|
||||||
ko_questions_data = minio_client.download_asset_file(self.tenant_id, ko_questions_asset.bucket_name,
|
ko_questions_data = minio_client.download_asset_file(self.tenant_id, ko_questions_asset.bucket_name,
|
||||||
ko_questions_asset.object_name)
|
ko_questions_asset.object_name)
|
||||||
ko_questions = KOQuestions.from_json(ko_questions_data)
|
ko_questions = KOQuestions.from_json(ko_questions_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user