- Add configuration of agents, tasks, tools, specialist in context of SPIN specialist
- correct startup of applications using gevent - introduce startup scripts (eveai_app) - caching manager for all configurations
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import (StringField, BooleanField, SelectField, TextAreaField)
|
||||
from wtforms.validators import DataRequired, Length
|
||||
from wtforms.validators import DataRequired, Length, Optional
|
||||
|
||||
from wtforms_sqlalchemy.fields import QuerySelectMultipleField
|
||||
|
||||
from common.models.document import Retriever
|
||||
from common.models.interaction import EveAITool
|
||||
from common.extensions import cache_manager
|
||||
|
||||
from config.type_defs.specialist_types import SPECIALIST_TYPES
|
||||
from .dynamic_form_base import DynamicFormBase
|
||||
|
||||
|
||||
@@ -14,6 +15,10 @@ def get_retrievers():
|
||||
return Retriever.query.all()
|
||||
|
||||
|
||||
def get_tools():
|
||||
return EveAITool.query.all()
|
||||
|
||||
|
||||
class SpecialistForm(FlaskForm):
|
||||
name = StringField('Name', validators=[DataRequired(), Length(max=50)])
|
||||
description = TextAreaField('Description', validators=[DataRequired()])
|
||||
@@ -32,8 +37,9 @@ class SpecialistForm(FlaskForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
types_dict = cache_manager.specialist_config_cache.get_types()
|
||||
# Dynamically populate the 'type' field using the constructor
|
||||
self.type.choices = [(key, value['name']) for key, value in SPECIALIST_TYPES.items()]
|
||||
self.type.choices = [(key, value['name']) for key, value in types_dict.items()]
|
||||
|
||||
|
||||
class EditSpecialistForm(DynamicFormBase):
|
||||
@@ -52,4 +58,59 @@ class EditSpecialistForm(DynamicFormBase):
|
||||
tuning = BooleanField('Enable Retrieval Tuning', default=False)
|
||||
|
||||
|
||||
class BaseComponentForm(DynamicFormBase):
|
||||
"""Base form for all processing components"""
|
||||
name = StringField('Name', validators=[DataRequired(), Length(max=50)])
|
||||
description = TextAreaField('Description', validators=[Optional()])
|
||||
type = SelectField('Type', validators=[DataRequired()])
|
||||
tuning = BooleanField('Enable Tuning', default=False)
|
||||
|
||||
def __init__(self, *args, type_config=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if type_config:
|
||||
self.type.choices = [(key, value['name']) for key, value in type_config.items()]
|
||||
|
||||
|
||||
# Edit forms that support dynamic fields
|
||||
class BaseEditComponentForm(DynamicFormBase):
|
||||
name = StringField('Name', validators=[DataRequired()])
|
||||
description = TextAreaField('Description', validators=[Optional()])
|
||||
type = StringField('Type', validators=[DataRequired()], render_kw={'readonly': True})
|
||||
tuning = BooleanField('Enable Tuning', default=False)
|
||||
|
||||
|
||||
class EveAIAgentForm(BaseComponentForm):
|
||||
role = TextAreaField('Role', validators=[DataRequired()])
|
||||
goal = TextAreaField('Goal', validators=[DataRequired()])
|
||||
backstory = TextAreaField('Backstory', validators=[DataRequired()])
|
||||
|
||||
tools = QuerySelectMultipleField(
|
||||
'Tools',
|
||||
query_factory=get_tools,
|
||||
get_label='name',
|
||||
allow_blank=True,
|
||||
description='Select one or more tools that can be used this agent'
|
||||
)
|
||||
|
||||
def __init__(self, *args, type_config=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if type_config:
|
||||
self.type.choices = [(key, value['name']) for key, value in type_config.items()]
|
||||
|
||||
|
||||
class EditEveAIAgentForm(BaseEditComponentForm):
|
||||
role = StringField('Role', validators=[DataRequired()])
|
||||
goal = StringField('Goal', validators=[DataRequired()])
|
||||
backstory = StringField('Backstory', validators=[DataRequired()])
|
||||
|
||||
tools = QuerySelectMultipleField(
|
||||
'Tools',
|
||||
query_factory=get_tools,
|
||||
get_label='name',
|
||||
allow_blank=True,
|
||||
description='Select one or more tools that can be used this agent'
|
||||
)
|
||||
|
||||
|
||||
class EveAITaskForm(BaseComponentForm):
|
||||
expected_output = TextAreaField('Expected Output', validators=[DataRequired()])
|
||||
|
||||
Reference in New Issue
Block a user