This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
from openai import OpenAI
from env_util import OPENAI_BASE_URL, OPENAI_API_KEY
# 这里采用原生的OpenAI的API去玩。
# 1、 拿到OpenAI的Client
client = OpenAI(
base_url=OPENAI_BASE_URL,
api_key=OPENAI_API_KEY,
);
# 2、 调用Embedding模型,获取text的向量
text = "i like LLM.";
resp = client.embeddings.create(
model='text-embedding-3-large',
dimensions=512, # 向量的维度~~
input=text
# 3、输出结果
print(resp.data[0].embedding)
print(len(resp.data[0].embedding))