feat: Generation Page AI workflows + AI/Vector modules + exam session fixes
Generation Page (complete rebuild): - Full production-parity exam generation wizard with 4 IELTS modules - Reading: AI passage gen, 5 exercise types (MCQ, Fill, Write, T/F, Match) - Listening: 4 section types, AI context gen, TTS audio gen (ElevenLabs) - Writing: Task 1/2, AI instruction gen, word limits, marks - Speaking: 3 parts, AI script gen, avatar video gen (7 avatars) - Per-module config: timer, CEFR difficulty, access, approval, rubrics - Exam submission workflow (draft/published) Exam Structures: - New encoach.exam.structure model + CRUD controller - ExamStructuresPage wired to real API AI Module (encoach_ai): - OpenAI service, ElevenLabs TTS, AWS Polly, ELAI avatars - AI settings model with Odoo config parameters - 7 generation endpoints (passage, exercises, instructions, scripts, context) Vector Module (encoach_vector): - pgvector integration for RAG-based content search - Embedding service with sentence-transformers Exam Session Fixes: - Fixed ExamSession.tsx field mapping (question_type→type, exam_title→title) - Fixed submit payload to include attempt_id and answers - Fixed normalizeType to handle null/undefined Tested: 12/12 API tests passed, browser-verified with real OpenAI calls Made-with: Cursor
This commit is contained in:
2
backend/custom_addons/encoach_ai/models/__init__.py
Normal file
2
backend/custom_addons/encoach_ai/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import ai_settings
|
||||
from . import ai_log
|
||||
35
backend/custom_addons/encoach_ai/models/ai_log.py
Normal file
35
backend/custom_addons/encoach_ai/models/ai_log.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class EncoachAILog(models.Model):
|
||||
_name = "encoach.ai.log"
|
||||
_description = "AI Service Call Log"
|
||||
_order = "create_date desc"
|
||||
|
||||
service = fields.Selection(
|
||||
[
|
||||
("openai", "OpenAI"),
|
||||
("whisper", "Whisper"),
|
||||
("polly", "AWS Polly"),
|
||||
("elevenlabs", "ElevenLabs"),
|
||||
("gptzero", "GPTZero"),
|
||||
("elai", "ELAI"),
|
||||
("coach", "AI Coach"),
|
||||
],
|
||||
required=True,
|
||||
index=True,
|
||||
)
|
||||
action = fields.Char(index=True)
|
||||
model_used = fields.Char()
|
||||
prompt_tokens = fields.Integer(default=0)
|
||||
completion_tokens = fields.Integer(default=0)
|
||||
total_tokens = fields.Integer(default=0)
|
||||
latency_ms = fields.Integer()
|
||||
status = fields.Selection(
|
||||
[("success", "Success"), ("error", "Error"), ("timeout", "Timeout")],
|
||||
default="success",
|
||||
)
|
||||
error_message = fields.Text()
|
||||
user_id = fields.Many2one("res.users", default=lambda self: self.env.uid)
|
||||
input_preview = fields.Text()
|
||||
output_preview = fields.Text()
|
||||
79
backend/custom_addons/encoach_ai/models/ai_settings.py
Normal file
79
backend/custom_addons/encoach_ai/models/ai_settings.py
Normal file
@@ -0,0 +1,79 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class EncoachAISettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
# ── OpenAI ──
|
||||
ai_openai_api_key = fields.Char(
|
||||
string="OpenAI API Key",
|
||||
config_parameter="encoach_ai.openai_api_key",
|
||||
)
|
||||
ai_openai_model = fields.Selection(
|
||||
[("gpt-4o", "GPT-4o"), ("gpt-4o-mini", "GPT-4o Mini"), ("gpt-3.5-turbo", "GPT-3.5 Turbo")],
|
||||
string="OpenAI Model",
|
||||
default="gpt-4o",
|
||||
config_parameter="encoach_ai.openai_model",
|
||||
)
|
||||
ai_openai_fast_model = fields.Selection(
|
||||
[("gpt-4o-mini", "GPT-4o Mini"), ("gpt-3.5-turbo", "GPT-3.5 Turbo")],
|
||||
string="OpenAI Fast Model",
|
||||
default="gpt-3.5-turbo",
|
||||
config_parameter="encoach_ai.openai_fast_model",
|
||||
)
|
||||
|
||||
# ── AWS Polly ──
|
||||
ai_aws_access_key = fields.Char(
|
||||
string="AWS Access Key ID",
|
||||
config_parameter="encoach_ai.aws_access_key",
|
||||
)
|
||||
ai_aws_secret_key = fields.Char(
|
||||
string="AWS Secret Access Key",
|
||||
config_parameter="encoach_ai.aws_secret_key",
|
||||
)
|
||||
ai_aws_region = fields.Char(
|
||||
string="AWS Region",
|
||||
default="eu-west-1",
|
||||
config_parameter="encoach_ai.aws_region",
|
||||
)
|
||||
|
||||
# ── ElevenLabs ──
|
||||
ai_elevenlabs_api_key = fields.Char(
|
||||
string="ElevenLabs API Key",
|
||||
config_parameter="encoach_ai.elevenlabs_api_key",
|
||||
)
|
||||
ai_elevenlabs_model = fields.Char(
|
||||
string="ElevenLabs Model",
|
||||
default="eleven_multilingual_v2",
|
||||
config_parameter="encoach_ai.elevenlabs_model",
|
||||
)
|
||||
ai_tts_provider = fields.Selection(
|
||||
[("polly", "AWS Polly"), ("elevenlabs", "ElevenLabs")],
|
||||
string="TTS Provider",
|
||||
default="polly",
|
||||
config_parameter="encoach_ai.tts_provider",
|
||||
)
|
||||
|
||||
# ── GPTZero ──
|
||||
ai_gptzero_api_key = fields.Char(
|
||||
string="GPTZero API Key",
|
||||
config_parameter="encoach_ai.gptzero_api_key",
|
||||
)
|
||||
|
||||
# ── ELAI ──
|
||||
ai_elai_token = fields.Char(
|
||||
string="ELAI Token",
|
||||
config_parameter="encoach_ai.elai_token",
|
||||
)
|
||||
|
||||
# ── Operational ──
|
||||
ai_max_retries = fields.Integer(
|
||||
string="Max Generation Retries",
|
||||
default=3,
|
||||
config_parameter="encoach_ai.max_retries",
|
||||
)
|
||||
ai_enabled = fields.Boolean(
|
||||
string="AI Services Enabled",
|
||||
default=True,
|
||||
config_parameter="encoach_ai.enabled",
|
||||
)
|
||||
Reference in New Issue
Block a user