Variables for rag_context and fallback algorithms added to Tenant and parts of the implementation.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from flask import current_app
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import (StringField, PasswordField, BooleanField, SubmitField, EmailField, IntegerField, DateField,
|
||||
SelectField, SelectMultipleField, FieldList, FormField, FloatField)
|
||||
SelectField, SelectMultipleField, FieldList, FormField, FloatField, TextAreaField)
|
||||
from wtforms.validators import DataRequired, Length, Email, NumberRange, Optional
|
||||
import pytz
|
||||
|
||||
@@ -16,6 +16,8 @@ class TenantForm(FlaskForm):
|
||||
allowed_languages = SelectMultipleField('Allowed Languages', choices=[], validators=[DataRequired()])
|
||||
# Timezone
|
||||
timezone = SelectField('Timezone', choices=[], validators=[DataRequired()])
|
||||
# RAG context
|
||||
rag_context = TextAreaField('RAG Context', validators=[Optional()])
|
||||
# LLM fields
|
||||
embedding_model = SelectField('Embedding Model', choices=[], validators=[DataRequired()])
|
||||
llm_model = SelectField('Large Language Model', choices=[], validators=[DataRequired()])
|
||||
@@ -37,6 +39,10 @@ class TenantForm(FlaskForm):
|
||||
es_similarity_threshold = FloatField('Similarity Threshold for Searching Embeddings (0.5)',
|
||||
default=0.5,
|
||||
validators=[NumberRange(min=0, max=1)])
|
||||
# Chat Variables
|
||||
chat_RAG_temperature = FloatField('RAG Temperature', default=0.3, validators=[NumberRange(min=0, max=1)])
|
||||
chat_no_RAG_temperature = FloatField('No RAG Temperature', default=0.5, validators=[NumberRange(min=0, max=1)])
|
||||
fallback_algorithms = SelectMultipleField('Fallback Algorithms', choices=[], validators=[Optional()])
|
||||
# Tuning variables
|
||||
embed_tuning = BooleanField('Enable Embedding Tuning', default=False)
|
||||
rag_tuning = BooleanField('Enable RAG Tuning', default=False)
|
||||
@@ -53,6 +59,8 @@ class TenantForm(FlaskForm):
|
||||
# initialise LLM fields
|
||||
self.embedding_model.choices = [(model, model) for model in current_app.config['SUPPORTED_EMBEDDINGS']]
|
||||
self.llm_model.choices = [(model, model) for model in current_app.config['SUPPORTED_LLMS']]
|
||||
# Initialize fallback algorithms
|
||||
self.fallback_algorithms.choices = [(algorithm, algorithm.lower()) for algorithm in current_app.config['FALLBACK_ALGORITHMS']]
|
||||
|
||||
|
||||
class BaseUserForm(FlaskForm):
|
||||
|
||||
@@ -45,18 +45,20 @@ def tenant():
|
||||
if form.validate_on_submit():
|
||||
current_app.logger.debug('Creating new tenant')
|
||||
# Handle the required attributes
|
||||
new_tenant = Tenant(name=form.name.data,
|
||||
website=form.website.data,
|
||||
default_language=form.default_language.data,
|
||||
allowed_languages=form.allowed_languages.data,
|
||||
timezone=form.timezone.data,
|
||||
embedding_model=form.embedding_model.data,
|
||||
llm_model=form.llm_model.data,
|
||||
license_start_date=form.license_start_date.data,
|
||||
license_end_date=form.license_end_date.data,
|
||||
allowed_monthly_interactions=form.allowed_monthly_interactions.data,
|
||||
embed_tuning=form.embed_tuning.data,
|
||||
rag_tuning=form.rag_tuning.data)
|
||||
new_tenant = Tenant()
|
||||
form.populate_obj(new_tenant)
|
||||
# new_tenant = Tenant(name=form.name.data,
|
||||
# website=form.website.data,
|
||||
# default_language=form.default_language.data,
|
||||
# allowed_languages=form.allowed_languages.data,
|
||||
# timezone=form.timezone.data,
|
||||
# embedding_model=form.embedding_model.data,
|
||||
# llm_model=form.llm_model.data,
|
||||
# license_start_date=form.license_start_date.data,
|
||||
# license_end_date=form.license_end_date.data,
|
||||
# allowed_monthly_interactions=form.allowed_monthly_interactions.data,
|
||||
# embed_tuning=form.embed_tuning.data,
|
||||
# rag_tuning=form.rag_tuning.data)
|
||||
|
||||
# Handle Embedding Variables
|
||||
new_tenant.html_tags = form.html_tags.data.split(',') if form.html_tags.data else []
|
||||
|
||||
Reference in New Issue
Block a user