- Created a new eveai_chat plugin to support the new dynamic possibilities of the Specialists. Currently only supports standard Rag retrievers (i.e. no extra arguments).
This commit is contained in:
@@ -10,6 +10,17 @@
|
||||
<div class="container">
|
||||
<form method="POST" action="{{ url_for('document_bp.handle_library_selection') }}">
|
||||
<div class="form-group mt-3">
|
||||
<h2>Create Default RAG Library</h2>
|
||||
<p>This function will create a default library setup for RAG purposes. More specifically, it will create:</p>
|
||||
<ul>
|
||||
<li>A default RAG Catalog</li>
|
||||
<li>A Default HTML Processor</li>
|
||||
<li>A default RAG Retriever</li>
|
||||
<li>A default RAG Specialist</li>
|
||||
</ul>
|
||||
<p>This enables a quick start-up for standard Ask Eve AI functionality. All elements can be changed later on an individual basis.</p>
|
||||
<button type="submit" name="action" value="create_default_rag_library" class="btn btn-danger">Create Default RAG Library</button>
|
||||
|
||||
<h2>Re-Embed Latest Versions</h2>
|
||||
<p>This functionality will re-apply embeddings on the latest versions of all documents in the library.
|
||||
This is useful only while tuning the embedding parameters, or when changing embedding algorithms.
|
||||
@@ -17,6 +28,7 @@
|
||||
use it with caution!
|
||||
</p>
|
||||
<button type="submit" name="action" value="re_embed_latest_versions" class="btn btn-danger">Re-embed Latest Versions (expensive)</button>
|
||||
|
||||
<h2>Refresh all documents</h2>
|
||||
<p>This operation will create new versions of all documents in the library with a URL. Documents that were uploaded directly,
|
||||
cannot be automatically refreshed. This is an expensive operation, and impacts the performance of the system in future use.
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
{% block content %}
|
||||
<form action="{{ url_for('entitlements_bp.handle_license_selection') }}" method="POST">
|
||||
{{ render_selectable_table(headers=["License ID", "Name", "Start Date", "End Date", "Active"], rows=rows, selectable=True, id="licensesTable") }}
|
||||
<!-- <div class="form-group mt-3">-->
|
||||
<!-- <button type="submit" name="action" value="edit_user" class="btn btn-primary">Edit Selected User</button>-->
|
||||
<!-- <button type="submit" name="action" value="resend_confirmation_email" class="btn btn-secondary">Resend Confirmation Email</button>-->
|
||||
<!-- <button type="submit" name="action" value="send_password_reset_email" class="btn btn-secondary">Send Password Reset Email</button>-->
|
||||
<!-- <button type="submit" name="action" value="reset_uniquifier" class="btn btn-secondary">Reset Uniquifier</button>-->
|
||||
<!-- <!– Additional buttons can be added here for other actions –>-->
|
||||
<!-- </div>-->
|
||||
<div class="form-group mt-3">
|
||||
<button type="submit" name="action" value="edit_license" class="btn btn-primary">Edit License</button>
|
||||
<!-- Additional buttons can be added here for other actions -->
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "macros.html" import render_field %}
|
||||
|
||||
{% block title %}Session Overview{% endblock %}
|
||||
|
||||
{% block content_title %}Session Overview{% endblock %}
|
||||
@@ -8,7 +6,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-5">
|
||||
<h2>Chat Session Details</h2>
|
||||
<h4>Chat Session Details</h4>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5>Session Information</h5>
|
||||
@@ -21,44 +19,73 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Interactions</h3>
|
||||
<h5>Interactions</h5>
|
||||
<div class="accordion" id="interactionsAccordion">
|
||||
{% for interaction in interactions %}
|
||||
{% for interaction, id, question_at, specialist_arguments, specialist_results, specialist_name, specialist_type in interactions %}
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="heading{{ loop.index }}">
|
||||
<p class="accordion-header" id="heading{{ loop.index }}">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#collapse{{ loop.index }}" aria-expanded="false"
|
||||
aria-controls="collapse{{ loop.index }}">
|
||||
<div class="d-flex justify-content-between align-items-center w-100">
|
||||
<span class="interaction-question">{{ interaction.question | truncate(50) }}</span>
|
||||
<span class="interaction-icons">
|
||||
<i class="material-icons algorithm-icon {{ interaction.algorithm_used | lower }}">fingerprint</i>
|
||||
<i class="material-icons thumb-icon {% if interaction.appreciation == 100 %}filled{% else %}outlined{% endif %}">thumb_up</i>
|
||||
<i class="material-icons thumb-icon {% if interaction.appreciation == 0 %}filled{% else %}outlined{% endif %}">thumb_down</i>
|
||||
</span>
|
||||
<div class="interaction-header">
|
||||
<div class="interaction-metadata">
|
||||
<div class="interaction-time text-muted">
|
||||
{{ question_at | to_local_time(chat_session.timezone) }}
|
||||
</div>
|
||||
<div class="specialist-info">
|
||||
<span class="badge bg-primary">{{ specialist_name if specialist_name else 'No Specialist' }}</span>
|
||||
<span class="badge bg-secondary">{{ specialist_type if specialist_type else '' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="interaction-question">
|
||||
{{ specialist_results.detailed_query if specialist_results and specialist_results.detailed_query else specialist_arguments.query }}
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</h2>
|
||||
</p>
|
||||
<div id="collapse{{ loop.index }}" class="accordion-collapse collapse" aria-labelledby="heading{{ loop.index }}"
|
||||
data-bs-parent="#interactionsAccordion">
|
||||
<div class="accordion-body">
|
||||
<h6>Detailed Question:</h6>
|
||||
<p>{{ interaction.detailed_question }}</p>
|
||||
<h6>Answer:</h6>
|
||||
<div class="markdown-content">{{ interaction.answer | safe }}</div>
|
||||
{% if embeddings_dict.get(interaction.id) %}
|
||||
<h6>Related Documents:</h6>
|
||||
<ul>
|
||||
{% for embedding in embeddings_dict[interaction.id] %}
|
||||
<li>
|
||||
{% if embedding.url %}
|
||||
<a href="{{ embedding.url }}" target="_blank">{{ embedding.url }}</a>
|
||||
{% else %}
|
||||
{{ embedding.object_name }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<!-- Arguments Section -->
|
||||
{% if specialist_arguments %}
|
||||
<div class="mb-4">
|
||||
<h6 class="mb-3">Specialist Arguments:</h6>
|
||||
<div class="code-wrapper">
|
||||
<pre><code class="language-json" style="width: 100%;">{{ specialist_arguments | tojson(indent=2) }}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Results Section -->
|
||||
{% if specialist_results %}
|
||||
<div class="mb-4">
|
||||
<h6 class="mb-3">Specialist Results:</h6>
|
||||
<div class="code-wrapper">
|
||||
<pre><code class="language-json" style="width: 100%;">{{ specialist_results | tojson(indent=2) }}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Related Documents Section -->
|
||||
{% if embeddings_dict.get(id) %}
|
||||
<div class="mt-4">
|
||||
<h6>Related Documents:</h6>
|
||||
<ul class="list-group">
|
||||
{% for embedding in embeddings_dict[id] %}
|
||||
<li class="list-group-item">
|
||||
{% if embedding.url %}
|
||||
<a href="{{ embedding.url }}" target="_blank" class="text-decoration-none">
|
||||
<i class="material-icons align-middle me-2">link</i>
|
||||
{{ embedding.url }}
|
||||
</a>
|
||||
{% else %}
|
||||
<i class="material-icons align-middle me-2">description</i>
|
||||
{{ embedding.object_name }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -68,14 +95,166 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
{{ super() }}
|
||||
<style>
|
||||
.interaction-header {
|
||||
font-size: 0.9rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
padding: 0.5rem 0;
|
||||
}
|
||||
|
||||
.interaction-metadata {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.interaction-time {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.specialist-info {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.interaction-question {
|
||||
font-size: 0.9rem;
|
||||
font-weight: bold;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-size: 0.9rem;
|
||||
padding: 0.35em 0.65em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.accordion-button {
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.accordion-button::after {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.json-display {
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
padding: 15px;
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
font-family: monospace;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.5;
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.list-group-item {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.material-icons {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
white-space: pre-wrap !important; /* Force wrapping */
|
||||
word-wrap: break-word !important; /* Break long words if necessary */
|
||||
max-width: 100%; /* Ensure container doesn't overflow */
|
||||
}
|
||||
|
||||
pre, code {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
white-space: pre-wrap !important; /* Force wrapping */
|
||||
word-wrap: break-word !important; /* Break long words if necessary */
|
||||
max-width: 100%; /* Ensure container doesn't overflow */
|
||||
}
|
||||
|
||||
pre code {
|
||||
padding: 1rem !important;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap !important; /* Force wrapping in code block */
|
||||
}
|
||||
|
||||
.code-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Override all possible highlight.js white-space settings */
|
||||
.code-wrapper pre,
|
||||
.code-wrapper pre code,
|
||||
.code-wrapper pre code.hljs,
|
||||
.code-wrapper .hljs {
|
||||
white-space: pre-wrap !important;
|
||||
overflow-wrap: break-word !important;
|
||||
word-wrap: break-word !important;
|
||||
word-break: break-word !important;
|
||||
max-width: 100% !important;
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
|
||||
.code-wrapper pre {
|
||||
margin: 0;
|
||||
background: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.code-wrapper pre code {
|
||||
padding: 1rem !important;
|
||||
font-family: monospace;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.5;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Override highlight.js default nowrap behavior */
|
||||
.hljs {
|
||||
background: #f8f9fa !important;
|
||||
white-space: pre-wrap !important;
|
||||
word-wrap: break-word !important;
|
||||
}
|
||||
|
||||
/* Color theme */
|
||||
.hljs-string {
|
||||
color: #0a3069 !important;
|
||||
}
|
||||
|
||||
.hljs-attr {
|
||||
color: #953800 !important;
|
||||
}
|
||||
|
||||
.hljs-number {
|
||||
color: #116329 !important;
|
||||
}
|
||||
|
||||
.hljs-boolean {
|
||||
color: #0550ae !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
{{ super() }}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var markdownElements = document.querySelectorAll('.markdown-content');
|
||||
markdownElements.forEach(function(el) {
|
||||
el.innerHTML = marked.parse(el.textContent);
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize syntax highlighting
|
||||
document.querySelectorAll('pre code').forEach((block) => {
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,3 +1,81 @@
|
||||
{% macro render_field_content(field, disabled=False, class='') %}
|
||||
{% if field.type == 'BooleanField' %}
|
||||
<div class="form-group">
|
||||
<div class="form-check form-switch">
|
||||
{{ field(class="form-check-input " + class, disabled=disabled) }}
|
||||
{% if field.description %}
|
||||
{{ field.label(class="form-check-label",
|
||||
**{'data-bs-toggle': 'tooltip',
|
||||
'data-bs-placement': 'right',
|
||||
'title': field.description}) }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ field.label(class="form-check-label") }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if field.errors %}
|
||||
<div class="invalid-feedback d-block">
|
||||
{% for error in field.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="form-group">
|
||||
{% if field.description %}
|
||||
{{ field.label(class="form-label",
|
||||
**{'data-bs-toggle': 'tooltip',
|
||||
'data-bs-placement': 'right',
|
||||
'title': field.description}) }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ field.label(class="form-label") }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if field.type == 'TextAreaField' and 'json-editor' in class %}
|
||||
<div id="{{ field.id }}-editor" class="json-editor-container"></div>
|
||||
{{ field(class="form-control d-none " + class, disabled=disabled) }}
|
||||
{% elif field.type == 'SelectField' %}
|
||||
{{ field(class="form-control form-select " + class, disabled=disabled) }}
|
||||
{% else %}
|
||||
{{ field(class="form-control " + class, disabled=disabled) }}
|
||||
{% endif %}
|
||||
|
||||
{% if field.errors %}
|
||||
<div class="invalid-feedback d-block">
|
||||
{% for error in field.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro render_field(field, disabled_fields=[], exclude_fields=[], class='') %}
|
||||
<!-- Debug info -->
|
||||
<!-- Field name: {{ field.name }}, Field type: {{ field.__class__.__name__ }} -->
|
||||
@@ -5,157 +83,14 @@
|
||||
{% set disabled = field.name in disabled_fields %}
|
||||
{% set exclude_fields = exclude_fields + ['csrf_token', 'submit'] %}
|
||||
{% if field.name not in exclude_fields %}
|
||||
{% if field.type == 'BooleanField' %}
|
||||
<div class="form-group">
|
||||
<div class="form-check form-switch">
|
||||
{{ field(class="form-check-input " + class, disabled=disabled) }}
|
||||
{% if field.description %}
|
||||
{{ field.label(class="form-check-label",
|
||||
**{'data-bs-toggle': 'tooltip',
|
||||
'data-bs-placement': 'right',
|
||||
'title': field.description}) }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ field.label(class="form-check-label") }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if field.errors %}
|
||||
<div class="invalid-feedback d-block">
|
||||
{% for error in field.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="form-group">
|
||||
{% if field.description %}
|
||||
{{ field.label(class="form-label",
|
||||
**{'data-bs-toggle': 'tooltip',
|
||||
'data-bs-placement': 'right',
|
||||
'title': field.description}) }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ field.label(class="form-label") }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if field.type == 'TextAreaField' and 'json-editor' in class %}
|
||||
<div id="{{ field.id }}-editor" class="json-editor-container"></div>
|
||||
{{ field(class="form-control d-none " + class, disabled=disabled) }}
|
||||
{% elif field.type == 'SelectField' %}
|
||||
{{ field(class="form-control form-select " + class, disabled=disabled) }}
|
||||
{% else %}
|
||||
{{ field(class="form-control " + class, disabled=disabled) }}
|
||||
{% endif %}
|
||||
|
||||
{% if field.errors %}
|
||||
<div class="invalid-feedback d-block">
|
||||
{% for error in field.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ render_field_content(field, disabled, class) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_included_field(field, disabled_fields=[], include_fields=[]) %}
|
||||
{% macro render_included_field(field, disabled_fields=[], include_fields=[], class='') %}
|
||||
{% set disabled = field.name in disabled_fields %}
|
||||
{% if field.name in include_fields %}
|
||||
{% if field.type == 'BooleanField' %}
|
||||
<div class="form-check">
|
||||
{{ field(class="form-check-input", type="checkbox", id="flexSwitchCheckDefault") }}
|
||||
{% if field.description %}
|
||||
{{ field.label(class="form-check-label",
|
||||
for="flexSwitchCheckDefault",
|
||||
disabled=disabled,
|
||||
**{'data-bs-toggle': 'tooltip',
|
||||
'data-bs-placement': 'right',
|
||||
'title': field.description}) }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ field.label(class="form-check-label", for="flexSwitchCheckDefault", disabled=disabled) }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="form-group">
|
||||
{% if field.description %}
|
||||
<div class="field-label-wrapper">
|
||||
{{ field.label(class="form-label",
|
||||
**{'data-bs-toggle': 'tooltip',
|
||||
'data-bs-placement': 'right',
|
||||
'title': field.description}) }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="field-label-wrapper">
|
||||
{{ field.label(class="form-label") }}
|
||||
{% if field.flags.required %}
|
||||
<span class="required-field-indicator" aria-hidden="true">
|
||||
<i class="material-symbols-outlined required-icon">check_circle</i>
|
||||
</span>
|
||||
<span class="visually-hidden">Required field</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if field.type == 'TextAreaField' and 'json-editor' in field.render_kw.get('class', '') %}
|
||||
<div id="{{ field.id }}-editor" class="json-editor-container"></div>
|
||||
{{ field(class="form-control d-none", disabled=disabled) }}
|
||||
{% elif field.type == 'SelectField' %}
|
||||
{{ field(class="form-control form-select", disabled=disabled) }}
|
||||
{% else %}
|
||||
{{ field(class="form-control", disabled=disabled) }}
|
||||
{% endif %}
|
||||
|
||||
{% if field.errors %}
|
||||
<div class="invalid-feedback d-block">
|
||||
{% for error in field.errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ render_field_content(field, disabled, class) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
{'name': 'License Tier Registration', 'url': '/entitlements/license_tier', 'roles': ['Super User']},
|
||||
{'name': 'All License Tiers', 'url': '/entitlements/view_license_tiers', 'roles': ['Super User']},
|
||||
{'name': 'Trigger Actions', 'url': '/administration/trigger_actions', 'roles': ['Super User']},
|
||||
{'name': 'All Licenses', 'url': 'entitlements/view_licenses', 'roles': ['Super User', 'Tenant Admin']},
|
||||
{'name': 'All Licenses', 'url': '/entitlements/view_licenses', 'roles': ['Super User', 'Tenant Admin']},
|
||||
{'name': 'Usage', 'url': '/entitlements/view_usages', 'roles': ['Super User', 'Tenant Admin']},
|
||||
]) }}
|
||||
{% endif %}
|
||||
|
||||
@@ -9,65 +9,12 @@
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
{{ form.hidden_tag() }}
|
||||
<!-- Main Tenant Information -->
|
||||
{% set main_fields = ['name', 'website', 'default_language', 'allowed_languages', 'timezone','rag_context', 'type'] %}
|
||||
{% set disabled_fields = [] %}
|
||||
{% set exclude_fields = [] %}
|
||||
{% for field in form %}
|
||||
{{ render_included_field(field, disabled_fields=[], include_fields=main_fields) }}
|
||||
{{ render_field(field, disabled_fields, exclude_fields) }}
|
||||
{% endfor %}
|
||||
|
||||
<!-- Nav Tabs -->
|
||||
<div class="row mt-5">
|
||||
<div class="col-lg-12">
|
||||
<div class="nav-wrapper position-relative end-0">
|
||||
<ul class="nav nav-pills nav-fill p-1" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link mb-0 px-0 py-1 active" data-toggle="tab" href="#model-info-tab" role="tab" aria-controls="model-info" aria-selected="true">
|
||||
Model Information
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link mb-0 px-0 py-1" data-toggle="tab" href="#license-info-tab" role="tab" aria-controls="license-info" aria-selected="false">
|
||||
License Information
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content tab-space">
|
||||
<!-- Model Information Tab -->
|
||||
<div class="tab-pane fade show active" id="model-info-tab" role="tabpanel">
|
||||
{% set model_fields = ['embedding_model', 'llm_model'] %}
|
||||
{% for field in form %}
|
||||
{{ render_included_field(field, disabled_fields=[], include_fields=model_fields) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<!-- License Information Tab -->
|
||||
<div class="tab-pane fade" id="license-info-tab" role="tabpanel">
|
||||
{% set license_fields = ['currency', 'usage_email', ] %}
|
||||
{% for field in form %}
|
||||
{{ render_included_field(field, disabled_fields=[], include_fields=license_fields) }}
|
||||
{% endfor %}
|
||||
<!-- Register API Key Button -->
|
||||
<div class="form-group">
|
||||
<button type="button" class="btn btn-primary" onclick="generateNewChatApiKey()">Register Chat API Key</button>
|
||||
<button type="button" class="btn btn-primary" onclick="generateNewApiKey()">Register API Key</button>
|
||||
</div>
|
||||
<!-- API Key Display Field -->
|
||||
<div id="chat-api-key-field" style="display:none;">
|
||||
<label for="chat-api-key">Chat API Key:</label>
|
||||
<input type="text" id="chat-api-key" class="form-control" readonly>
|
||||
<button type="button" id="copy-chat-button" class="btn btn-primary">Copy to Clipboard</button>
|
||||
<p id="copy-chat-message" style="display:none;color:green;">Chat API key copied to clipboard</p>
|
||||
</div>
|
||||
<div id="api-key-field" style="display:none;">
|
||||
<label for="api-key">API Key:</label>
|
||||
<input type="text" id="api-key" class="form-control" readonly>
|
||||
<button type="button" id="copy-api-button" class="btn btn-primary">Copy to Clipboard</button>
|
||||
<p id="copy-message" style="display:none;color:green;">API key copied to clipboard</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Save Tenant</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -78,88 +25,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
// Function to generate a new Chat API Key
|
||||
function generateNewChatApiKey() {
|
||||
generateApiKey('/admin/user/generate_chat_api_key', '#chat-api-key', '#chat-api-key-field');
|
||||
}
|
||||
|
||||
// Function to generate a new general API Key
|
||||
function generateNewApiKey() {
|
||||
generateApiKey('/admin/user/generate_api_api_key', '#api-key', '#api-key-field');
|
||||
}
|
||||
|
||||
// Reusable function to handle API key generation
|
||||
function generateApiKey(url, inputSelector, fieldSelector) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
success: function(response) {
|
||||
$(inputSelector).val(response.api_key);
|
||||
$(fieldSelector).show();
|
||||
},
|
||||
error: function(error) {
|
||||
alert('Error generating new API key: ' + error.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to copy text to clipboard
|
||||
function copyToClipboard(selector, messageSelector) {
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
const text = element.value;
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(text).then(function() {
|
||||
showCopyMessage(messageSelector);
|
||||
}).catch(function(error) {
|
||||
alert('Failed to copy text: ' + error);
|
||||
});
|
||||
} else {
|
||||
fallbackCopyToClipboard(text, messageSelector);
|
||||
}
|
||||
} else {
|
||||
console.error('Element not found for selector:', selector);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback method for copying text to clipboard
|
||||
function fallbackCopyToClipboard(text, messageSelector) {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
showCopyMessage(messageSelector);
|
||||
} catch (err) {
|
||||
alert('Fallback: Oops, unable to copy', err);
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
|
||||
// Function to show copy confirmation message
|
||||
function showCopyMessage(messageSelector) {
|
||||
const message = document.querySelector(messageSelector);
|
||||
if (message) {
|
||||
message.style.display = 'block';
|
||||
setTimeout(function() {
|
||||
message.style.display = 'none';
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
// Event listeners for copy buttons
|
||||
document.getElementById('copy-chat-button').addEventListener('click', function() {
|
||||
copyToClipboard('#chat-api-key', '#copy-chat-message');
|
||||
});
|
||||
|
||||
document.getElementById('copy-api-button').addEventListener('click', function() {
|
||||
copyToClipboard('#api-key', '#copy-message');
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// JavaScript to detect user's timezone
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
|
||||
Reference in New Issue
Block a user