Add AI stack configuration: ELAI avatars, system params, training tips import
- Add ELAI avatar seed data (7 avatars with codes, URLs, voice configs) from the original backend's avatars.json - Add missing system parameters: encoach.aws_region (eu-west-1), encoach.whisper_workers (4) - Add training tips import script with pathways_2_rw.json data source - Add action_compute_embeddings() method to training tip model for computing sentence-transformer embeddings on demand Made-with: Cursor
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
from odoo import models, fields
|
||||
import logging
|
||||
import pickle
|
||||
|
||||
from odoo import api, models, fields
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EncoachTrainingTip(models.Model):
|
||||
@@ -20,3 +25,24 @@ class EncoachTrainingTip(models.Model):
|
||||
)
|
||||
content = fields.Text(required=True)
|
||||
embedding = fields.Binary(string="FAISS Embedding Vector")
|
||||
|
||||
def action_compute_embeddings(self):
|
||||
"""Compute sentence-transformer embeddings for tips missing them."""
|
||||
try:
|
||||
from sentence_transformers import SentenceTransformer
|
||||
import numpy as np
|
||||
except ImportError:
|
||||
_logger.error("sentence-transformers not installed; cannot compute embeddings")
|
||||
return
|
||||
|
||||
tips = self.search([("embedding", "=", False)])
|
||||
if not tips:
|
||||
_logger.info("All tips already have embeddings")
|
||||
return
|
||||
|
||||
model = SentenceTransformer("all-MiniLM-L6-v2")
|
||||
for tip in tips:
|
||||
vec = model.encode([tip.content]).astype(np.float32)[0]
|
||||
tip.embedding = pickle.dumps(vec)
|
||||
|
||||
_logger.info("Computed embeddings for %d tips", len(tips))
|
||||
|
||||
Reference in New Issue
Block a user