from django.shortcuts import render

# Create your views here.
from django.http import JsonResponse

def get_text_embedding(request):
    text = request.GET.get('text', '')
    existing_embedding = retrieve_embedding(text)
    
    if existing_embedding:
        embeddings = existing_embedding
    else:
        embeddings = get_embeddings([text])[0].numpy().tolist()  # Ajustado para obtener el embedding y convertirlo a lista
        save_embedding(text, embeddings)
    
    return JsonResponse({"embeddings": embeddings})
