- Created a base mail template - Adapt and improve document API to usage of catalogs and processors - Adapt eveai_sync to new authentication mechanism and usage of catalogs and processors
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
from flask_wtf import FlaskForm
|
|
from wtforms import (StringField, BooleanField, SelectField, TextAreaField)
|
|
from wtforms.validators import DataRequired, Length
|
|
|
|
from wtforms_sqlalchemy.fields import QuerySelectMultipleField
|
|
|
|
from common.models.document import Retriever
|
|
|
|
from config.type_defs.specialist_types import SPECIALIST_TYPES
|
|
from .dynamic_form_base import DynamicFormBase
|
|
|
|
|
|
def get_retrievers():
|
|
return Retriever.query.all()
|
|
|
|
|
|
class SpecialistForm(FlaskForm):
|
|
name = StringField('Name', validators=[DataRequired(), Length(max=50)])
|
|
description = TextAreaField('Description', validators=[DataRequired()])
|
|
|
|
retrievers = QuerySelectMultipleField(
|
|
'Retrievers',
|
|
query_factory=get_retrievers,
|
|
get_label='name', # Assuming your Retriever model has a 'name' field
|
|
allow_blank=True,
|
|
description='Select one or more retrievers to associate with this specialist'
|
|
)
|
|
|
|
type = SelectField('Specialist Type', validators=[DataRequired()])
|
|
|
|
tuning = BooleanField('Enable Specialist Tuning', default=False)
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
# Dynamically populate the 'type' field using the constructor
|
|
self.type.choices = [(key, value['name']) for key, value in SPECIALIST_TYPES.items()]
|
|
|
|
|
|
class EditSpecialistForm(DynamicFormBase):
|
|
name = StringField('Name', validators=[DataRequired()])
|
|
description = TextAreaField('Description', validators=[DataRequired()])
|
|
|
|
retrievers = QuerySelectMultipleField(
|
|
'Retrievers',
|
|
query_factory=get_retrievers,
|
|
get_label='name',
|
|
allow_blank=True,
|
|
description='Select one or more retrievers to associate with this specialist'
|
|
)
|
|
|
|
type = StringField('Specialist Type', validators=[DataRequired()], render_kw={'readonly': True})
|
|
tuning = BooleanField('Enable Retrieval Tuning', default=False)
|
|
|
|
|
|
|