- Verbeterde versie Selectie Specialist - voor demo (1.2)
This commit is contained in:
@@ -509,7 +509,8 @@ export const ChatApp = {
|
|||||||
description: fieldDef.description || '',
|
description: fieldDef.description || '',
|
||||||
required: fieldDef.required || false,
|
required: fieldDef.required || false,
|
||||||
default: fieldDef.default || '',
|
default: fieldDef.default || '',
|
||||||
allowedValues: fieldDef.allowed_values || null
|
allowedValues: fieldDef.allowed_values || null,
|
||||||
|
context: fieldDef.context || null
|
||||||
}));
|
}));
|
||||||
} else if (Array.isArray(formRequest.fields)) {
|
} else if (Array.isArray(formRequest.fields)) {
|
||||||
// Als het al een array is, zorg dat alle velden correct zijn
|
// Als het al een array is, zorg dat alle velden correct zijn
|
||||||
@@ -520,7 +521,8 @@ export const ChatApp = {
|
|||||||
description: field.description || '',
|
description: field.description || '',
|
||||||
required: field.required || false,
|
required: field.required || false,
|
||||||
default: field.default || field.defaultValue || '',
|
default: field.default || field.defaultValue || '',
|
||||||
allowedValues: field.allowed_values || field.allowedValues || null
|
allowedValues: field.allowed_values || field.allowedValues || null,
|
||||||
|
context: field.context || null
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
// Fallback naar lege array als er geen velden zijn
|
// Fallback naar lege array als er geen velden zijn
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ export const DynamicForm = {
|
|||||||
<template v-if="field.type === 'enum' && (field.allowedValues || field.allowed_values)">
|
<template v-if="field.type === 'enum' && (field.allowedValues || field.allowed_values)">
|
||||||
{{ localFormValues[field.id || field.name] || field.default || '-' }}
|
{{ localFormValues[field.id || field.name] || field.default || '-' }}
|
||||||
</template>
|
</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'">
|
<template v-else-if="field.type === 'boolean'">
|
||||||
{{ localFormValues[field.id || field.name] ? 'Ja' : 'Nee' }}
|
{{ localFormValues[field.id || field.name] ? 'Ja' : 'Nee' }}
|
||||||
</template>
|
</template>
|
||||||
@@ -180,6 +183,9 @@ export const DynamicForm = {
|
|||||||
<template v-if="field.type === 'enum' && (field.allowedValues || field.allowed_values)">
|
<template v-if="field.type === 'enum' && (field.allowedValues || field.allowed_values)">
|
||||||
{{ localFormValues[fieldId] || field.default || '-' }}
|
{{ localFormValues[fieldId] || field.default || '-' }}
|
||||||
</template>
|
</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'">
|
<template v-else-if="field.type === 'boolean'">
|
||||||
{{ localFormValues[fieldId] ? 'Ja' : 'Nee' }}
|
{{ localFormValues[fieldId] ? 'Ja' : 'Nee' }}
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export const FormField = {
|
|||||||
'float': 'number',
|
'float': 'number',
|
||||||
'text': 'textarea',
|
'text': 'textarea',
|
||||||
'enum': 'select',
|
'enum': 'select',
|
||||||
|
'options': 'radio',
|
||||||
'boolean': 'checkbox'
|
'boolean': 'checkbox'
|
||||||
};
|
};
|
||||||
return typeMap[this.field.type] || this.field.type;
|
return typeMap[this.field.type] || this.field.type;
|
||||||
@@ -75,6 +76,10 @@ export const FormField = {
|
|||||||
|
|
||||||
<!-- Container voor input velden -->
|
<!-- Container voor input velden -->
|
||||||
<div style="width: 100%;">
|
<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) -->
|
<!-- Tekstinvoer (string/str) -->
|
||||||
<input
|
<input
|
||||||
v-if="fieldType === 'text'"
|
v-if="fieldType === 'text'"
|
||||||
@@ -135,10 +140,43 @@ export const FormField = {
|
|||||||
style="color: #d93025; font-size: 0.85em; margin-top: 4px;">
|
style="color: #d93025; font-size: 0.85em; margin-top: 4px;">
|
||||||
Geen opties beschikbaar voor dit veld.
|
Geen opties beschikbaar voor dit veld.
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<!-- Toggle switch voor boolean velden, met speciale layout voor deze velden -->
|
<!-- 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;">
|
<div class="toggle-switch" style="position: relative; display: inline-block; width: 50px; height: 24px;">
|
||||||
<input
|
<input
|
||||||
:id="fieldId"
|
:id="fieldId"
|
||||||
@@ -168,6 +206,7 @@ export const FormField = {
|
|||||||
{{ field.description || '' }}
|
{{ field.description || '' }}
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -102,18 +102,11 @@ class SpecialistResult(BaseModel):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Structural optional fields available for all specialists
|
# Structural optional fields available for all specialists
|
||||||
answer: Optional[str] = Field(
|
answer: Optional[str] = Field(None, description="Optional textual answer from the specialist")
|
||||||
None,
|
detailed_query: Optional[str] = Field(None, description="Optional detailed query for the specialist")
|
||||||
description="Optional textual answer from 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")
|
||||||
detailed_query: Optional[str] = Field(
|
citations: Optional[Dict[str, Any]] = Field(None, description="Citations for the specialist's answer")
|
||||||
None,
|
|
||||||
description="Optional detailed query for the specialist"
|
|
||||||
)
|
|
||||||
form_request: Optional[Dict[str, Any]] = Field(
|
|
||||||
None,
|
|
||||||
description="Optional form definition to request user input"
|
|
||||||
)
|
|
||||||
|
|
||||||
@model_validator(mode='after')
|
@model_validator(mode='after')
|
||||||
def validate_required_results(self) -> 'SpecialistResult':
|
def validate_required_results(self) -> 'SpecialistResult':
|
||||||
|
|||||||
@@ -95,16 +95,63 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
|||||||
sleep(1)
|
sleep(1)
|
||||||
self.ept.send_update(self.task_id, "Traicie Selection Specialist Processing", {"name": f"Processing Iteration {i}"})
|
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()))
|
if not self._cached_session.interactions:
|
||||||
# flow_state = self.flow.state
|
specialist_phase = "initial"
|
||||||
# results = RoleDefinitionSpecialistResult.create_for_type(self.type, self.type_version)
|
else:
|
||||||
contact_form = cache_manager.specialist_forms_config_cache.get_config("PERSONAL_CONTACT_FORM", "1.0")
|
specialist_phase = self._cached_session.interactions[-1].specialist_results.get('phase', 'initial')
|
||||||
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)
|
|
||||||
|
|
||||||
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 collega’s 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
|
return results
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user