- Add include_minoxidil_beard flag to SuggestRoutineRequest and SuggestBatchRequest - Detect minoxidil products by scanning name, brand, INCI and actives; pass them to the LLM even though they are medications - Inject CELE UŻYTKOWNIKA context block into prompts when flag is enabled - Add _build_objectives_context() returning empty string when flag is off - Add call_gemini() helper that centralises Gemini API calls and logs every request/response to a new ai_call_logs table (AICallLog model + /ai-logs router) - Nginx: raise client_max_body_size to 16 MB for photo uploads Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
"""add_ai_call_logs
|
|
|
|
Revision ID: a1b2c3d4e5f6
|
|
Revises: c2d626a2b36c
|
|
Create Date: 2026-03-01 00:00:00.000000
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
import sqlmodel.sql.sqltypes
|
|
|
|
from alembic import op
|
|
|
|
revision: str = "a1b2c3d4e5f6"
|
|
down_revision: Union[str, None] = "c2d626a2b36c"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"ai_call_logs",
|
|
sa.Column("id", sa.Uuid(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("endpoint", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column("model", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column("system_prompt", sa.Text(), nullable=True),
|
|
sa.Column("user_input", sa.Text(), nullable=True),
|
|
sa.Column("response_text", sa.Text(), nullable=True),
|
|
sa.Column("prompt_tokens", sa.Integer(), nullable=True),
|
|
sa.Column("completion_tokens", sa.Integer(), nullable=True),
|
|
sa.Column("total_tokens", sa.Integer(), nullable=True),
|
|
sa.Column("duration_ms", sa.Integer(), nullable=True),
|
|
sa.Column("success", sa.Boolean(), nullable=False),
|
|
sa.Column("error_detail", sa.Text(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_ai_call_logs_endpoint"), "ai_call_logs", ["endpoint"], unique=False
|
|
)
|
|
op.create_index(
|
|
op.f("ix_ai_call_logs_success"), "ai_call_logs", ["success"], unique=False
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f("ix_ai_call_logs_success"), table_name="ai_call_logs")
|
|
op.drop_index(op.f("ix_ai_call_logs_endpoint"), table_name="ai_call_logs")
|
|
op.drop_table("ai_call_logs")
|