Skip to content
Snippets Groups Projects
Unverified Commit 3bf5c22c authored by James Briggs's avatar James Briggs
Browse files

adapted old typing style

parent 5a31fa77
No related branches found
No related tags found
No related merge requests found
import os import os
from time import sleep from time import sleep
from typing import List, Optional
import openai import openai
from openai import OpenAIError from openai import OpenAIError
...@@ -10,21 +11,21 @@ from semantic_router.utils.logger import logger ...@@ -10,21 +11,21 @@ from semantic_router.utils.logger import logger
class AzureOpenAIEncoder(BaseEncoder): class AzureOpenAIEncoder(BaseEncoder):
client: openai.AzureOpenAI | None = None client: Optional[openai.AzureOpenAI] = None
type: str = "azure" type: str = "azure"
api_key: str | None = None api_key: Optional[str] = None
deployment_name: str | None = None deployment_name: Optional[str] = None
azure_endpoint: str | None = None azure_endpoint: Optional[str] = None
api_version: str | None = None api_version: Optional[str] = None
model: str | None = None model: Optional[str] = None
def __init__( def __init__(
self, self,
api_key: str | None = None, api_key: Optional[str] = None,
deployment_name: str | None = None, deployment_name: Optional[str] = None,
azure_endpoint: str | None = None, azure_endpoint: Optional[str] = None,
api_version: str | None = None, api_version: Optional[str] = None,
model: str | None = None, model: Optional[str] = None,
score_threshold: float = 0.82, score_threshold: float = 0.82,
): ):
name = deployment_name name = deployment_name
...@@ -75,7 +76,7 @@ class AzureOpenAIEncoder(BaseEncoder): ...@@ -75,7 +76,7 @@ class AzureOpenAIEncoder(BaseEncoder):
except Exception as e: except Exception as e:
raise ValueError(f"OpenAI API client failed to initialize. Error: {e}") raise ValueError(f"OpenAI API client failed to initialize. Error: {e}")
def __call__(self, docs: list[str]) -> list[list[float]]: def __call__(self, docs: List[str]) -> List[List[float]]:
if self.client is None: if self.client is None:
raise ValueError("OpenAI client is not initialized.") raise ValueError("OpenAI client is not initialized.")
embeds = None embeds = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment