forked from Azure-Samples/rag-postgres-openai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_embeddings.py
More file actions
30 lines (25 loc) · 1.07 KB
/
Copy pathtest_embeddings.py
File metadata and controls
30 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest
from fastapi_app.embeddings import compute_text_embedding
from fastapi_app.openai_clients import create_openai_embed_client
from tests.data import test_data
@pytest.mark.asyncio
async def test_compute_text_embedding(mock_azure_credential, mock_openai_embedding):
openai_embed_client = await create_openai_embed_client(mock_azure_credential)
result = await compute_text_embedding(
q="test",
openai_client=openai_embed_client,
embed_model="text-embedding-ada-002",
embed_deployment="text-embedding-ada-002",
)
assert result == test_data.embeddings
@pytest.mark.asyncio
async def test_compute_text_embedding_dimensions(mock_azure_credential, mock_openai_embedding):
openai_embed_client = await create_openai_embed_client(mock_azure_credential)
result = await compute_text_embedding(
q="test",
openai_client=openai_embed_client,
embed_model="text-embedding-3-small",
embed_deployment="text-embedding-3-small",
embedding_dimensions=1024,
)
assert result == test_data.embeddings