2023-05-11 16:06:39 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# preload the embedding model, useful for Docker images to prevent re-download on config change
|
|
|
|
# Dockerfile:
|
|
|
|
# ENV OPENEDAI_EMBEDDING_MODEL=all-mpnet-base-v2 # Optional
|
|
|
|
# RUN python3 cache_embedded_model.py
|
2023-09-16 05:11:16 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
import sentence_transformers
|
2023-09-18 03:39:29 +02:00
|
|
|
from extensions.openai.script import params
|
2023-09-16 05:11:16 +02:00
|
|
|
|
2023-09-18 03:39:29 +02:00
|
|
|
st_model = os.environ.get("OPENEDAI_EMBEDDING_MODEL", params.get('embedding_model', 'all-mpnet-base-v2'))
|
2023-05-11 16:06:39 +02:00
|
|
|
model = sentence_transformers.SentenceTransformer(st_model)
|