Skip to content

Commit

Permalink
lint and formatter execution on Azure llm fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Arash Mosharraf committed Jan 18, 2024
1 parent bbfa83a commit 0ecadd2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fastembed = {version = "^0.1.3", optional = true, python = "<3.12"}
torch = {version = "^2.1.2", optional = true}
transformers = {version = "^4.36.2", optional = true}
llama-cpp-python = {version = "^0.2.28", optional = true}
black = "^23.12.1"

[tool.poetry.extras]
hybrid = ["pinecone-text"]
Expand Down
2 changes: 1 addition & 1 deletion semantic_router/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from semantic_router.encoders import BaseEncoder, OpenAIEncoder
from semantic_router.linear import similarity_matrix, top_scores
from semantic_router.llms import BaseLLM, OpenAILLM, AzureOpenAILLM
from semantic_router.llms import AzureOpenAILLM, BaseLLM, OpenAILLM
from semantic_router.route import Route
from semantic_router.schema import Encoder, EncoderType, RouteChoice
from semantic_router.utils.logger import logger
Expand Down
11 changes: 9 additions & 2 deletions semantic_router/llms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
from semantic_router.llms.cohere import CohereLLM
from semantic_router.llms.llamacpp import LlamaCppLLM
from semantic_router.llms.openai import OpenAILLM
from semantic_router.llms.zure import AzureOpenAILLM
from semantic_router.llms.openrouter import OpenRouterLLM
from semantic_router.llms.zure import AzureOpenAILLM

__all__ = ["BaseLLM", "OpenAILLM", "OpenRouterLLM", "CohereLLM", "LlamaCppLLM", "AzureOpenAILLM"]
__all__ = [
"BaseLLM",
"OpenAILLM",
"OpenRouterLLM",
"CohereLLM",
"LlamaCppLLM",
"AzureOpenAILLM",
]
2 changes: 1 addition & 1 deletion semantic_router/llms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def extract_function_inputs(
"""
llm_input = [Message(role="user", content=prompt)]
output = self(llm_input)

if not output:
raise Exception("No output generated for extract function input")

Expand Down
9 changes: 5 additions & 4 deletions semantic_router/llms/zure.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def __init__(
self,
name: Optional[str] = None,
openai_api_key: Optional[str] = None,
azure_endpoint:Optional[str] = None,
azure_endpoint: Optional[str] = None,
temperature: float = 0.01,
max_tokens: int = 200,
api_version="2023-07-01-preview"
api_version="2023-07-01-preview",
):
if name is None:
name = os.getenv("OPENAI_CHAT_MODEL_NAME", "gpt-35-turbo")
Expand All @@ -32,8 +32,9 @@ def __init__(
if azure_endpoint is None:
raise ValueError("Azure endpoint API key cannot be 'None'.")
try:
self.client = openai.AzureOpenAI(api_key=api_key, azure_endpoint=azure_endpoint
, api_version=api_version)
self.client = openai.AzureOpenAI(
api_key=api_key, azure_endpoint=azure_endpoint, api_version=api_version
)
except Exception as e:
raise ValueError(f"OpenAI API client failed to initialize. Error: {e}")
self.temperature = temperature
Expand Down
2 changes: 1 addition & 1 deletion semantic_router/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Route(BaseModel):
description: Optional[str] = None
function_schema: Optional[Dict[str, Any]] = None
llm: Optional[BaseLLM] = None

def __call__(self, query: str) -> RouteChoice:
logger.info(f"this is the llm passed to route object {self.llm}")
if self.function_schema:
Expand Down

0 comments on commit 0ecadd2

Please sign in to comment.