Add extra chunking information in Tenant schema

Add extra scripts for flask-migrate to support refactoring
This commit is contained in:
Josako
2024-05-08 17:40:42 +02:00
parent cd5afa0408
commit bf6d91527b
9 changed files with 173 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
from flask import session
from flask_wtf import FlaskForm
from wtforms import (StringField, BooleanField, SubmitField, DateField,
SelectField, FieldList, FormField)
SelectField, FieldList, FormField, TextAreaField)
from wtforms.validators import DataRequired, Length, Optional
from flask_wtf.file import FileField, FileAllowed, FileRequired
@@ -11,6 +11,7 @@ class AddDocumentForm(FlaskForm):
FileRequired()])
name = StringField('Name', validators=[Length(max=100)])
language = SelectField('Language', choices=[], validators=[Optional()])
user_context = TextAreaField('User Context', validators=[Optional()])
valid_from = DateField('Valid from', id='form-control datepicker', validators=[Optional()])
doc_embedding_model = SelectField('Default Embedding Model', choices=[], validators=[DataRequired()])

View File

@@ -48,7 +48,7 @@ def add_document():
set_logging_information(new_doc, dt.now(tz.utc))
# Create the DocumentLanguage
new_doc_lang = create_language_for_document(new_doc, form.language.data)
new_doc_lang = create_language_for_document(new_doc, form.language.data, form.user_context.data)
# Create the DocumentVersion
new_doc_vers = DocumentVersion()
@@ -122,13 +122,16 @@ def set_logging_information(obj, timestamp):
obj.updated_by = current_user.id
def create_language_for_document(document, language):
def create_language_for_document(document, language, user_context):
new_doc_lang = DocumentLanguage()
if language == '':
new_doc_lang.language = session['default_language']
else:
new_doc_lang.language = language
if user_context != '':
new_doc_lang.user_context = user_context
new_doc_lang.document = document
set_logging_information(new_doc_lang, dt.now(tz.utc))