{% extends "base.html" %} {% block title %}{{ _("Ask · Local SQL Agent") }}{% endblock %} {% block content %} {% set sample_questions = [ _("Top 5 customers by purchase value in 1402"), _("Trade volume in the cement ring in Mordad 1405"), _("Which ring had the highest sales in 1404?"), _("Total purchase value by month in 1405"), _("How many active customers exist?"), _("Sales on Thursdays in the petrochemical ring"), _("Top 5 brokers by purchase value in 1403"), _("Sales in the Kish export ring in 1402"), ] %}

{{ _("Ask your question") }}

{{ _("English or Persian — the agent will answer against the database.") }}

{% if result %}

{{ _("Results") }}

{% if result.status == "SUCCESS" %} {{ _("SUCCESS") }} {% else %} {{ _("ERROR") }} {% endif %} {{ _("model") }}: {{ result.model or "—" }} · {% if current_lang == "fa" %}{{ result.elapsed_seconds }} {{ _("s") }}{% else %}{{ result.elapsed_seconds }}{{ _("s") }}{% endif %}

{{ _("Question:") }} {{ result.question }}

{% if result.sql %}
{{ _("Generated SQL") }}
{{ result.sql }}
{% endif %} {% if result.interpretation %}

{{ result.interpretation }}

{% endif %} {% if result.columns %}
{% for col in result.columns %}{% endfor %} {% for row in result.rows %} {% for col in result.columns %}{% endfor %} {% endfor %}
{{ col }}
{{ row[col] }}

{% if current_lang == "fa" %} {{ result.row_count }} ردیف {% else %} {{ result.row_count }} row{{ "s" if result.row_count != 1 }} {% endif %}

{% elif result.status == "SUCCESS" %}

{{ _("No rows returned for this question.") }}

{% endif %} {% if output_filename %}
{% endif %}
{% endif %}
{% endblock %}