- Refinenement of improved RAG_SPECIALIST
- Changed label of RetrieverType in Retriever form
This commit is contained in:
@@ -140,21 +140,17 @@ def enforce_tenant_consent_ui():
|
|||||||
"""Check if the user has consented to the terms of service"""
|
"""Check if the user has consented to the terms of service"""
|
||||||
path = getattr(request, 'path', '') or ''
|
path = getattr(request, 'path', '') or ''
|
||||||
if path.startswith('/healthz') or path.startswith('/_healthz'):
|
if path.startswith('/healthz') or path.startswith('/_healthz'):
|
||||||
current_app.logger.debug(f'Health check request, bypassing consent guard: {path}')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not current_user.is_authenticated:
|
if not current_user.is_authenticated:
|
||||||
current_app.logger.debug('Not authenticated, bypassing consent guard')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
endpoint = request.endpoint or ''
|
endpoint = request.endpoint or ''
|
||||||
if is_exempt_endpoint(endpoint) or request.method == 'OPTIONS':
|
if is_exempt_endpoint(endpoint) or request.method == 'OPTIONS':
|
||||||
current_app.logger.debug(f'Endpoint exempt from consent guard: {endpoint}')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Global bypass: Super User and Partner Admin always allowed
|
# Global bypass: Super User and Partner Admin always allowed
|
||||||
if current_user.has_roles('Super User') or current_user.has_roles('Partner Admin'):
|
if current_user.has_roles('Super User') or current_user.has_roles('Partner Admin'):
|
||||||
current_app.logger.debug('Global bypass: Super User or Partner Admin')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
tenant_id = getattr(current_user, 'tenant_id', None)
|
tenant_id = getattr(current_user, 'tenant_id', None)
|
||||||
@@ -176,16 +172,13 @@ def enforce_tenant_consent_ui():
|
|||||||
status = ConsentStatus.NOT_CONSENTED
|
status = ConsentStatus.NOT_CONSENTED
|
||||||
|
|
||||||
if status == ConsentStatus.CONSENTED:
|
if status == ConsentStatus.CONSENTED:
|
||||||
current_app.logger.debug('User has consented')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if status == ConsentStatus.NOT_CONSENTED:
|
if status == ConsentStatus.NOT_CONSENTED:
|
||||||
current_app.logger.debug('User has not consented')
|
|
||||||
if current_user.has_roles('Tenant Admin'):
|
if current_user.has_roles('Tenant Admin'):
|
||||||
return redirect(prefixed_url_for('user_bp.tenant_consent', for_redirect=True))
|
return redirect(prefixed_url_for('user_bp.tenant_consent', for_redirect=True))
|
||||||
return redirect(prefixed_url_for('user_bp.no_consent', for_redirect=True))
|
return redirect(prefixed_url_for('user_bp.no_consent', for_redirect=True))
|
||||||
if status == ConsentStatus.RENEWAL_REQUIRED:
|
if status == ConsentStatus.RENEWAL_REQUIRED:
|
||||||
current_app.logger.debug('Consent renewal required')
|
|
||||||
if current_user.has_roles('Tenant Admin'):
|
if current_user.has_roles('Tenant Admin'):
|
||||||
flash(
|
flash(
|
||||||
"You need to renew your consent to our DPA or T&Cs. Failing to do so in time will stop you from accessing our services.",
|
"You need to renew your consent to our DPA or T&Cs. Failing to do so in time will stop you from accessing our services.",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
version: "1.1.0"
|
version: "1.2.0"
|
||||||
name: "Rag Agent"
|
name: "Rag Agent"
|
||||||
role: >
|
role: >
|
||||||
{tenant_name}'s Spokesperson. {custom_role}
|
{tenant_name}'s Spokesperson. {custom_role}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ fields:
|
|||||||
email:
|
email:
|
||||||
name: "Email"
|
name: "Email"
|
||||||
type: "str"
|
type: "str"
|
||||||
description: "Your Name"
|
description: "Your Email"
|
||||||
required: true
|
required: true
|
||||||
phone:
|
phone:
|
||||||
name: "Phone Number"
|
name: "Phone Number"
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ def create_app(config_file=None):
|
|||||||
# Register global consent guard via extension
|
# Register global consent guard via extension
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def enforce_tenant_consent():
|
def enforce_tenant_consent():
|
||||||
app.logger.debug("Enforcing tenant consent")
|
|
||||||
return enforce_tenant_consent_ui()
|
return enforce_tenant_consent_ui()
|
||||||
|
|
||||||
# @app.before_request
|
# @app.before_request
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class EditRetrieverForm(DynamicFormBase):
|
|||||||
description = TextAreaField('Description', validators=[Optional()])
|
description = TextAreaField('Description', validators=[Optional()])
|
||||||
|
|
||||||
# Select Field for Retriever Type (Uses the RETRIEVER_TYPES defined in config)
|
# Select Field for Retriever Type (Uses the RETRIEVER_TYPES defined in config)
|
||||||
type = StringField('Processor Type', validators=[DataRequired()], render_kw={'readonly': True})
|
type = StringField('Retriever Type', validators=[DataRequired()], render_kw={'readonly': True})
|
||||||
type_version = StringField('Retriever Type Version', validators=[DataRequired()], render_kw={'readonly': True})
|
type_version = StringField('Retriever Type Version', validators=[DataRequired()], render_kw={'readonly': True})
|
||||||
tuning = BooleanField('Enable Tuning', default=False)
|
tuning = BooleanField('Enable Tuning', default=False)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import random
|
||||||
from os import wait
|
from os import wait
|
||||||
from typing import Optional, List, Dict, Any
|
from typing import Optional, List, Dict, Any
|
||||||
|
|
||||||
@@ -117,7 +118,7 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
|||||||
self.log_tuning("RAG Specialist rag_state execution started", {})
|
self.log_tuning("RAG Specialist rag_state execution started", {})
|
||||||
|
|
||||||
insufficient_info_message = TranslationServices.translate(self.tenant_id,
|
insufficient_info_message = TranslationServices.translate(self.tenant_id,
|
||||||
INSUFFICIENT_INFORMATION_MESSAGE,
|
random.choice(INSUFFICIENT_INFORMATION_MESSAGES),
|
||||||
arguments.language)
|
arguments.language)
|
||||||
|
|
||||||
formatted_context, citations = self._retrieve_context(arguments)
|
formatted_context, citations = self._retrieve_context(arguments)
|
||||||
@@ -175,6 +176,14 @@ class RAGSpecialistInput(BaseModel):
|
|||||||
history: Optional[str] = Field(None, alias="history")
|
history: Optional[str] = Field(None, alias="history")
|
||||||
name: Optional[str] = Field(None, alias="name")
|
name: Optional[str] = Field(None, alias="name")
|
||||||
welcome_message: Optional[str] = Field(None, alias="welcome_message")
|
welcome_message: Optional[str] = Field(None, alias="welcome_message")
|
||||||
|
tone_of_voice: Optional[str] = Field(None, alias="tone_of_voice")
|
||||||
|
tone_of_voice_context: Optional[str] = Field(None, alias="tone_of_voice_context")
|
||||||
|
language_level: Optional[str] = Field(None, alias="language_level")
|
||||||
|
language_level_context: Optional[str] = Field(None, alias="language_level_context")
|
||||||
|
response_depth: Optional[str] = Field(None, alias="response_depth")
|
||||||
|
response_depth_context: Optional[str] = Field(None, alias="response_depth_context")
|
||||||
|
conversation_purpose: Optional[str] = Field(None, alias="conversation_purpose")
|
||||||
|
conversation_purpose_context: Optional[str] = Field(None, alias="conversation_purpose_context")
|
||||||
|
|
||||||
|
|
||||||
class RAGSpecialistResult(SpecialistResult):
|
class RAGSpecialistResult(SpecialistResult):
|
||||||
|
|||||||
Reference in New Issue
Block a user