- Verbeterde versie Selectie Specialist - voor demo (1.2)

This commit is contained in:
Josako
2025-06-16 11:06:20 +02:00
parent dbea41451a
commit 71adf64668
5 changed files with 111 additions and 24 deletions

View File

@@ -509,7 +509,8 @@ export const ChatApp = {
description: fieldDef.description || '',
required: fieldDef.required || false,
default: fieldDef.default || '',
allowedValues: fieldDef.allowed_values || null
allowedValues: fieldDef.allowed_values || null,
context: fieldDef.context || null
}));
} else if (Array.isArray(formRequest.fields)) {
// Als het al een array is, zorg dat alle velden correct zijn
@@ -520,7 +521,8 @@ export const ChatApp = {
description: field.description || '',
required: field.required || false,
default: field.default || field.defaultValue || '',
allowedValues: field.allowed_values || field.allowedValues || null
allowedValues: field.allowed_values || field.allowedValues || null,
context: field.context || null
}));
} else {
// Fallback naar lege array als er geen velden zijn

View File

@@ -160,6 +160,9 @@ export const DynamicForm = {
<template v-if="field.type === 'enum' && (field.allowedValues || field.allowed_values)">
{{ localFormValues[field.id || field.name] || field.default || '-' }}
</template>
<template v-else-if="field.type === 'options' && (field.allowedValues || field.allowed_values)">
{{ localFormValues[field.id || field.name] || field.default || '-' }}
</template>
<template v-else-if="field.type === 'boolean'">
{{ localFormValues[field.id || field.name] ? 'Ja' : 'Nee' }}
</template>
@@ -180,6 +183,9 @@ export const DynamicForm = {
<template v-if="field.type === 'enum' && (field.allowedValues || field.allowed_values)">
{{ localFormValues[fieldId] || field.default || '-' }}
</template>
<template v-else-if="field.type === 'options' && (field.allowedValues || field.allowed_values)">
{{ localFormValues[fieldId] || field.default || '-' }}
</template>
<template v-else-if="field.type === 'boolean'">
{{ localFormValues[fieldId] ? 'Ja' : 'Nee' }}
</template>

View File

@@ -46,6 +46,7 @@ export const FormField = {
'float': 'number',
'text': 'textarea',
'enum': 'select',
'options': 'radio',
'boolean': 'checkbox'
};
return typeMap[this.field.type] || this.field.type;
@@ -75,6 +76,10 @@ export const FormField = {
<!-- Container voor input velden -->
<div style="width: 100%;">
<!-- Context informatie indien aanwezig -->
<div v-if="field.context" class="field-context" style="margin-bottom: 8px; font-size: 0.9em; color: #666; background-color: #f8f9fa; padding: 8px; border-radius: 4px; border-left: 3px solid #4285f4;">
{{ field.context }}
</div>
<!-- Tekstinvoer (string/str) -->
<input
v-if="fieldType === 'text'"
@@ -135,10 +140,43 @@ export const FormField = {
style="color: #d93025; font-size: 0.85em; margin-top: 4px;">
Geen opties beschikbaar voor dit veld.
</div>
<!-- Radio buttons (options) -->
<div v-if="fieldType === 'radio'" class="radio-options">
<div v-for="option in (field.allowedValues || field.allowed_values || [])"
:key="option"
class="radio-option"
style="margin-bottom: 8px;">
<div style="display: flex; align-items: center;">
<input
type="radio"
:id="fieldId + '_' + option"
:name="fieldId"
:value="option"
v-model="value"
:required="field.required"
style="margin-right: 8px;"
>
<label :for="fieldId + '_' + option" style="cursor: pointer; margin-bottom: 0;">
{{ option }}
</label>
</div>
</div>
<!-- Debug info voor radio options -->
<div v-if="!(field.allowedValues || field.allowed_values) || (field.allowedValues || field.allowed_values).length === 0"
style="color: #d93025; font-size: 0.85em; margin-top: 4px;">
Geen opties beschikbaar voor dit veld.
</div>
</div>
</div>
<!-- Toggle switch voor boolean velden, met speciale layout voor deze velden -->
<div v-if="fieldType === 'checkbox'" style="grid-column: 1 / span 2; display: flex; align-items: center;">
<div v-if="fieldType === 'checkbox'" style="grid-column: 1 / span 2;">
<!-- Context informatie indien aanwezig -->
<div v-if="field.context" class="field-context" style="margin-bottom: 8px; font-size: 0.9em; color: #666; background-color: #f8f9fa; padding: 8px; border-radius: 4px; border-left: 3px solid #4285f4;">
{{ field.context }}
</div>
<div style="display: flex; align-items: center;">
<div class="toggle-switch" style="position: relative; display: inline-block; width: 50px; height: 24px;">
<input
:id="fieldId"
@@ -168,6 +206,7 @@ export const FormField = {
{{ field.description || '' }}
</span>
</label>
</div>
</div>
</div>
`

View File

@@ -102,18 +102,11 @@ class SpecialistResult(BaseModel):
}
# Structural optional fields available for all specialists
answer: Optional[str] = Field(
None,
description="Optional textual answer from the specialist"
)
detailed_query: Optional[str] = Field(
None,
description="Optional detailed query for the specialist"
)
form_request: Optional[Dict[str, Any]] = Field(
None,
description="Optional form definition to request user input"
)
answer: Optional[str] = Field(None, description="Optional textual answer from the specialist")
detailed_query: Optional[str] = Field(None, description="Optional detailed query for the specialist")
form_request: Optional[Dict[str, Any]] = Field(None, description="Optional form definition to request user input")
phase: Optional[str] = Field(None, description="Phase of the specialist's workflow")
citations: Optional[Dict[str, Any]] = Field(None, description="Citations for the specialist's answer")
@model_validator(mode='after')
def validate_required_results(self) -> 'SpecialistResult':

View File

@@ -95,16 +95,63 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
sleep(1)
self.ept.send_update(self.task_id, "Traicie Selection Specialist Processing", {"name": f"Processing Iteration {i}"})
# 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)
contact_form = cache_manager.specialist_forms_config_cache.get_config("PERSONAL_CONTACT_FORM", "1.0")
current_app.logger.debug(f"Contact form: {contact_form}")
results = SpecialistResult.create_for_type(self.type, self.type_version,
answer=f"Antwoord op uw vraag: {arguments.question}",
form_request=contact_form)
if not self._cached_session.interactions:
specialist_phase = "initial"
else:
specialist_phase = self._cached_session.interactions[-1].specialist_results.get('phase', 'initial')
self.log_tuning(f"Traicie Selection Specialist execution ended", {"Results": results.model_dump()})
results = None
match specialist_phase:
case "initial":
ko_form = form_definition = {
"type": "KO_CRITERIA_FORM",
"version": "1.0.0",
"name": "KO Criteria Form",
"icon": "verified",
"fields": {
"weekend_werk": {
"name": "Weekend Werk",
"description": "Werken in het weekend",
"context": "Ben je bereid om in het weekend te werken?",
"type": "options",
"required": True,
"allowed_values": ["Ja, geen probleem", "Nee, liever niet"]
},
"fysisch_werk": {
"name": "Fysische Activiteit",
"description": "Fysisch werken",
"context": "In onze winkels is het belangrijk dat je 8u kan rechtstaan in een iets koeler omgeving. Is dit voor jou haalbaar?",
"type": "options",
"required": True,
"allowed_values": ["Ja, prima haalbaar", "Neen, mogelijks een probleem"]
},
"nabijheid_werk": {
"name": "Nabijheid Werk",
"description": "Afstand Woon-Werk",
"context": "We hebben gemerkt dat tevreden collegas in de buurt van de winkel wonen. Hoe ver wil jij je verplaatsen?",
"type": "options",
"required": True,
"allowed_values": ["Meer dan 15 km", "Minder dan 15 km"]
},
}
}
results = SpecialistResult.create_for_type(self.type, self.type_version,
answer=f"We starten met een aantal KO Criteria vragen",
form_request=ko_form,
phase="ko_questions")
case "ko_questions":
contact_form = cache_manager.specialist_forms_config_cache.get_config("PERSONAL_CONTACT_FORM", "1.0")
results = SpecialistResult.create_for_type(self.type, self.type_version,
answer=f"We hebben de antwoorden op de KO criteria verwerkt. Je bent een geschikte kandidaat. Kan je je contactegevens doorgeven?",
form_request=contact_form,
phase="personal_contact_data")
case "personal_contact_data":
results = SpecialistResult.create_for_type(self.type, self.type_version,
answer=f"We hebben de contactgegevens verwerkt. We nemen zo snel mogelijk contact met je op.",
phase="candidate_selected")
self.log_tuning(f"Traicie Selection Specialist execution ended", {"Results": results.model_dump() if results else "No info"})
return results