# coding=utf-8
import zhipuai
from embeddings.embedding import Embedding


class Zhipuembedding(Embedding):
    def __init__(self, **param):
        zhipuai.api_key = param['api_key']
        self.cache = {}

    def getem(self, question):
        response = zhipuai.model_api.invoke(model="text_embedding",
                                            prompt=question)
        em = response['data']['embedding']
        self.cache['question'] = em
        return em
