Skip to content

Develop#2

Open
oscarcitoz wants to merge 368 commits into
oscarcitoz:masterfrom
neuro-publico:develop
Open

Develop#2
oscarcitoz wants to merge 368 commits into
oscarcitoz:masterfrom
neuro-publico:develop

Conversation

@oscarcitoz

Copy link
Copy Markdown
Owner

No description provided.

oscarcitoz added 30 commits July 1, 2025 16:57
add logic for create context and brand for store
Julian Otalora and others added 30 commits April 18, 2026 02:43
…eaming-images

feat(section-html): SDK migration + image pipeline + dynamic prompts
Two minimal, surgical logging additions to SectionImageService._do_generate
that close the biggest visibility gaps we've hit during incident investigations.

Change 1 — persist Gemini raw text response on success
  Previously `log_prompt()` received no `response_text`, leaving the
  `prompt_logs.response_text` column NULL for all 11k+ section_image rows.
  Any debug of "why did this section turn out weird?" required reproducing
  the call end-to-end against Gemini (~60s + API cost) to see what the model
  actually replied. Now we capture the first 10KB of `text_response` right
  before `del`, and pass it through to `log_prompt`.

Change 2 — log every failed Gemini attempt, not only the final outcome
  Previously the 5-retry loop only logged the final outcome (success,
  fallback or error). Transient failures like "Gemini no image in response.
  finishReason: STOP, text: BOTONES:" or "empty parts" lived in stdout
  only and rotated out of CloudWatch within days. With this change each
  retry emits its own row with `status=attempt_failed`, its own
  `attempt_number`, `elapsed_ms`, and the truncated `error_message`, so
  failure-mode analysis (how often, what pattern, when in bursts) becomes
  a single SQL query against `prompt_logs`.

No existing behavior changes: success/fallback/error paths keep their
exact prior semantics. The final error log after fallback-also-fails is
preserved as-is. All prior fields of the success log are preserved.

Tests
  11 new unit tests in test_section_image_logging.py cover:
  - success path: response_text logged and truncated at 10KB
  - None/empty text_response is coerced to "" (no crash)
  - retry path: N attempt_failed rows + 1 final success
  - gemini-fail + openai-fallback-works: 5 + 1 rows
  - gemini-fail + openai-fail: 5 + 1 (original error raised)
  - error_message truncated at 1000 chars
  - backward-compat: every prior log field still present

Full suite: 416 passed, 1 skipped, 0 regressions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(logs): persist AI raw response + log each failed retry attempt
Two minimal, surgical logging additions to SectionImageService._do_generate
that close the biggest visibility gaps we've hit during incident investigations.

Change 1 — persist Gemini raw text response on success
  Previously `log_prompt()` received no `response_text`, leaving the
  `prompt_logs.response_text` column NULL for all 11k+ section_image rows.
  Any debug of "why did this section turn out weird?" required reproducing
  the call end-to-end against Gemini (~60s + API cost) to see what the model
  actually replied. Now we capture the first 10KB of `text_response` right
  before `del`, and pass it through to `log_prompt`.

Change 2 — log every failed Gemini attempt, not only the final outcome
  Previously the 5-retry loop only logged the final outcome (success,
  fallback or error). Transient failures like "Gemini no image in response.
  finishReason: STOP, text: BOTONES:" or "empty parts" lived in stdout
  only and rotated out of CloudWatch within days. With this change each
  retry emits its own row with `status=attempt_failed`, its own
  `attempt_number`, `elapsed_ms`, and the truncated `error_message`, so
  failure-mode analysis (how often, what pattern, when in bursts) becomes
  a single SQL query against `prompt_logs`.

No existing behavior changes: success/fallback/error paths keep their
exact prior semantics. The final error log after fallback-also-fails is
preserved as-is. All prior fields of the success log are preserved.

Tests
  11 new unit tests in test_section_image_logging.py cover:
  - success path: response_text logged and truncated at 10KB
  - None/empty text_response is coerced to "" (no crash)
  - retry path: N attempt_failed rows + 1 final success
  - gemini-fail + openai-fallback-works: 5 + 1 rows
  - gemini-fail + openai-fail: 5 + 1 (original error raised)
  - error_message truncated at 1000 chars
  - backward-compat: every prior log field still present

Full suite: 416 passed, 1 skipped, 0 regressions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…master

feat(logs): persist AI raw response + log each failed retry attempt (PROD)
Adds POST /analyze-funnel endpoint that analyzes ad funnel metrics and
returns a structured action plan. Ported from the n8n workflow
"Identificar constraints y prioridades", using Gemini Flash with
structured JSON output.

- AnalyzeFunnelRequest/Response DTOs with ad context, raw metrics, rates
- Semáforo (traffic-light) classifier with dropshipping_prospecting
  thresholds for hook_rate, thruplay_rate, ctr, cpc, roas, click_to_purchase
- Cerebro Estratégico system prompt ported verbatim from n8n
- Uses call_gemini_structured with gemini-flash-latest + responseSchema
- Audit logging via log_prompt to prompt_logs
- @require_api_key auth (server-to-server call from ecommerce-service)
- 28 unit tests covering classifier thresholds and service orchestration

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat: add funnel analysis AI agent ("Cerebro Estratégico")
Drop the interactive checklist section from SYSTEM_PROMPT, RESPONSE_SCHEMA,
and AnalyzeFunnelResponse. The action_plan list already covers the "what to
do" surface; the separate checklist was redundant and drove unnecessary UI
complexity (optimistic updates, rollback, PATCH endpoint).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…list

refactor: remove today_checklist from funnel analysis agent
# Conflicts:
#	app/services/section_image_service.py
#	scripts/seed_ai_prompts.sql
…hema-sync

feat: add UGC voiceover director support
…ture-cleanup

refactor: add voiceover service interfaces
…evelop-20260526

Merge production hotfixes into develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants