- Specialist Editor Change (all components in same overview), modal editors to allow for more complex configuration of Agents, Tasks and Tools
- Strengthening dynamic forms
This commit is contained in:
@@ -98,10 +98,17 @@ class EditEveAIAgentForm(BaseEditComponentForm):
|
||||
obj = kwargs.get('obj')
|
||||
agent_type = None
|
||||
agent_type_version = None
|
||||
current_llm_model = None
|
||||
current_temperature = None
|
||||
if obj:
|
||||
agent_type = obj.type
|
||||
agent_type_version = obj.type_version
|
||||
current_llm_model = obj.llm_model
|
||||
current_temperature = obj.temperature
|
||||
|
||||
# Bewaar flags over oorspronkelijke None-status voor optionele normalisatie in populate_obj
|
||||
self._was_llm_model_none = (current_llm_model is None)
|
||||
self._was_temperature_none = (current_temperature is None)
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@@ -111,6 +118,8 @@ class EditEveAIAgentForm(BaseEditComponentForm):
|
||||
self._agent_config = cache_manager.agents_config_cache.get_config(agent_type, agent_type_version)
|
||||
allowed_models = self._agent_config.get('allowed_models', None)
|
||||
full_model_name = self._agent_config.get('full_model_name', 'mistral.mistral-medium-latest')
|
||||
default_temperature = self._agent_config.get('temperature', 0.7)
|
||||
|
||||
if allowed_models:
|
||||
# Converteer lijst van strings naar lijst van tuples (value, label)
|
||||
self.llm_model.choices = [(model, model) for model in allowed_models]
|
||||
@@ -124,26 +133,36 @@ class EditEveAIAgentForm(BaseEditComponentForm):
|
||||
# Gebruik full_model_name als fallback
|
||||
self.llm_model.choices = [(full_model_name, full_model_name)]
|
||||
|
||||
# Als er GEEN waarde in de database staat, toon dan de default uit de config
|
||||
if not current_llm_model:
|
||||
self.llm_model.data = full_model_name
|
||||
# Defaults alleen instellen wanneer er geen formdata is (GET render of programmatic constructie)
|
||||
is_post = bool(getattr(self, 'formdata', None))
|
||||
if not is_post:
|
||||
if current_llm_model is None:
|
||||
self.llm_model.data = full_model_name
|
||||
if current_temperature is None:
|
||||
self.temperature.data = default_temperature
|
||||
else:
|
||||
self.llm_model.choices = [('mistral.mistral-medium-latest', 'mistral.mistral-medium-latest')]
|
||||
|
||||
def populate_obj(self, obj):
|
||||
"""Override populate_obj om de None waarde te behouden indien nodig"""
|
||||
original_llm_model = obj.llm_model
|
||||
|
||||
# Roep de parent populate_obj aan
|
||||
current_app.logger.info(f"populate_obj called with obj: {obj}")
|
||||
super().populate_obj(obj)
|
||||
current_app.logger.info(f"populate_obj done with obj: {obj}")
|
||||
|
||||
# Als de originele waarde None was EN de nieuwe waarde gelijk is aan de config default,
|
||||
# herstel dan de None waarde
|
||||
if original_llm_model is None and self._agent_config:
|
||||
# herstel dan de None waarde (alleen als het eerder None was)
|
||||
if getattr(self, '_agent_config', None):
|
||||
full_model_name = self._agent_config.get('full_model_name', 'mistral.mistral-medium-latest')
|
||||
if obj.llm_model == full_model_name:
|
||||
if self._was_llm_model_none and obj.llm_model == full_model_name:
|
||||
obj.llm_model = None
|
||||
|
||||
default_temperature = self._agent_config.get('temperature', 0.7)
|
||||
if self._was_temperature_none and obj.temperature == default_temperature:
|
||||
obj.temperature = None
|
||||
|
||||
current_app.logger.info(f"populate_obj default check results in obj: {obj}")
|
||||
|
||||
|
||||
class EditEveAITaskForm(BaseEditComponentForm):
|
||||
task_description = StringField('Task Description', validators=[Optional()])
|
||||
|
||||
Reference in New Issue
Block a user