{% extends "admin/base.html" %} {% set labels = { 'model': _('Model'), 'api_key_env': _('API key'), 'timeout_seconds': _('Time limit for an ordinary call, seconds'), 'page_read_timeout_seconds': _('Time limit for reading a web page, seconds'), } %} {% set by_name = {} %} {% for row in rows %}{% do by_name.update({row.name: row}) %}{% endfor %} {% macro key_text(k) %}{{ k.name }} – {% if k.source == 'page' %}{{ _('entered here') }}{% elif k.source == 'server' %}{{ _('set on the server') }}{% else %}{{ _('missing') }}{% endif %}{% if k.tail %} (…{{ k.tail }}){% endif %}{% if k.unreadable %}, {{ _('a key entered here cannot be read, enter it again') }}{% endif %}{% endmacro %} {% macro origin(name) %} {% set row = by_name[name] %} {% if row.saved and row.default %} {# Only when it matters: the server has a value of its own, and this one goes before it. #} {{ _('Applies instead of the server\'s value: {value}').format(value=row.default) }} {% endif %} {% for e in errors[name] or [] %}{{ e }}{% endfor %} {% endmacro %} {% block primary_content_inner %} {% asset 'ai_connector/ai-connector-settings' %}
{{ _('The connection to an AI service that the portal\'s extensions share: model, key and time limits. Changes apply at once, for the whole portal, without a restart. Where nothing is saved here, the server default applies. What each extension asks the AI to do is set on that extension\'s own pages.') }}
{% set problems = checks | selectattr('status', 'equalto', 'error') | list %}{% if problems %}{{ _('Something needs to be done before everything works:') }} {% else %}{{ _('Everything needed is in place.') }}{% endif %}
{{ check.fix }}{% endif %}
{{ _('Use the server\'s values? This changes:') }}
| {{ _('Setting') }} | {{ _('Now (saved here)') }} | {{ _('Becomes (the server\'s)') }} |
|---|---|---|
| {{ labels[name] }} | {{ by_name[name].value }} | {{ by_name[name].default }} |
{{ _('Other values saved here, and the API keys entered here, stay.') }}
{{ _('Cancel') }}{{ test.answer }}{% endif %}
{{ _('None yet.') }}
{% endif %} {% if can_store_keys %}{{ _('Adds a key without changing the model, for example before you switch service. The key is stored encrypted, goes only to the service you choose as the model, and is never shown again, only its last four characters.') }}
{#- Chosen first: what was sent (after an error), else the first service without a key. -#} {% set without_key = key_services | rejectattr('set') | list %} {% set chosen_service = request.form.get('custom_service', (without_key or key_services or [{'env': 'other'}])[0].env) %}{{ _('Start with the API key: add the key you got from your AI service under “Manage API keys” above. Then the model is chosen here, among that service\'s models.') }}
{% else %}{{ _('There is no API key yet, and this portal keeps its keys in the server configuration. Ask whoever runs the server to add one.') }}
{% endif %} {% else %} {% endif %} {% if purpose_rows and not first_time %} {#- Models for different purposes (API 2): an extension names what it uses the AI for, and each purpose may get a model of its own. Empty: the main model above. The key follows the model's service unless another is chosen. -#} {% set chosen_any = purpose_rows | selectattr('model') | list or purpose_rows | selectattr('broken') | list %}{{ _('An extension can use the AI for several things. Each can have a model of its own, for example a fast, inexpensive one for translation and a stronger one for reviews. Leave a model empty to use the main model above. The key is the one for the model\'s service, unless you choose another; it is never sent to another service.') }} {% if purpose_rows and purpose_rows[0].main_model %}{{ _('The main model is now {model}.').format(model=purpose_rows[0].main_model) }}{% endif %}