init
This commit is contained in:
21
tests/deno.ts
Normal file
21
tests/deno.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
const url = "http://10.39.39.9:7999/v1/embeddings";
|
||||
|
||||
const input: string[] = [];
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
input.push("我是一名大学生");
|
||||
}
|
||||
|
||||
const resp = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: "acge-large-zh",
|
||||
input,
|
||||
}),
|
||||
});
|
||||
|
||||
const result = await resp.json();
|
||||
|
||||
console.log(result);
|
||||
26
tests/openai_embedding_test.py
Normal file
26
tests/openai_embedding_test.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
测试 embedding 接口与 OpenAI 模块兼容性
|
||||
|
||||
需要将 embedding 接口提前部署在 localhost:7999/v1/embeddings
|
||||
"""
|
||||
|
||||
import requests
|
||||
import unittest
|
||||
import openai
|
||||
|
||||
url = "http://localhost:7999/v1/embeddings"
|
||||
|
||||
|
||||
class TestOpenAI(unittest.IsolatedAsyncioTestCase):
|
||||
async def testOpenAIEmbedding(self):
|
||||
client = openai.OpenAI(
|
||||
api_key="mikumikumi", base_url="http://localhost:7999/v1"
|
||||
)
|
||||
result = client.embeddings.create(
|
||||
model="acge-large-zh",
|
||||
input=["今天天气不错", "明天天气也不错"],
|
||||
)
|
||||
for i, data in enumerate(result.data):
|
||||
# acge 模型的 embedding 与 OpenAI 模型的 embedding 有一定差异
|
||||
# acge 向量维度为 1024,OpenAI 向量维度为 1536
|
||||
self.assertEqual(len(data.embedding), 1024)
|
||||
Reference in New Issue
Block a user