Skip to content

Commit

Permalink
oai v1 embeddings (#12969)
Browse files Browse the repository at this point in the history
Initial PR to get OpenAIEmbeddings working with the new sdk

fyi @rlancemartin

Fixes #12943

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
  • Loading branch information
2 people authored and rlancemartin committed Nov 7, 2023
1 parent 4c312cc commit 4bfcb4f
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions libs/langchain/tests/integration_tests/embeddings/test_openai.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Test openai embeddings."""
import os

import numpy as np
import openai
import pytest
Expand Down Expand Up @@ -90,26 +88,3 @@ def test_embed_documents_normalized() -> None:
def test_embed_query_normalized() -> None:
output = OpenAIEmbeddings().embed_query("foo walked to the market")
assert np.isclose(np.linalg.norm(output), 1.0)


def test_azure_openai_embeddings() -> None:
from openai import error

os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_BASE"] = "https://your-endpoint.openai.azure.com/"
os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key"
os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"

embeddings = OpenAIEmbeddings(deployment="your-embeddings-deployment-name")
text = "This is a test document."

try:
embeddings.embed_query(text)
except error.InvalidRequestError as e:
if "Must provide an 'engine' or 'deployment_id' parameter" in str(e):
assert (
False
), "deployment was provided to but openai.Embeddings didn't get it."
except Exception:
# Expected to fail because endpoint doesn't exist.
pass

0 comments on commit 4bfcb4f

Please sign in to comment.