Skip to content

Commit

Permalink
The baseurl is wrong for azure llm (#72)
Browse files Browse the repository at this point in the history
* Update Azure LLM base URL

* Update Azure LLM base URL

* Update docs
  • Loading branch information
harishmohanraj authored Aug 26, 2024
1 parent d53994d commit 0a472ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ search:
- azure
- [AzureOAI](api/fastagency/studio/models/llms/azure/AzureOAI.md)
- [AzureOAIAPIKey](api/fastagency/studio/models/llms/azure/AzureOAIAPIKey.md)
- [UrlModel](api/fastagency/studio/models/llms/azure/UrlModel.md)
- openai
- [OpenAI](api/fastagency/studio/models/llms/openai/OpenAI.md)
- [OpenAIAPIKey](api/fastagency/studio/models/llms/openai/OpenAIAPIKey.md)
Expand Down
11 changes: 11 additions & 0 deletions docs/docs/en/api/fastagency/studio/models/llms/azure/UrlModel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: fastagency.studio.models.llms.azure.UrlModel
8 changes: 6 additions & 2 deletions fastagency/studio/models/llms/azure.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Annotated, Any, Dict, Literal
from uuid import UUID

from pydantic import AfterValidator, Field, HttpUrl
from pydantic import AfterValidator, BaseModel, Field, HttpUrl
from typing_extensions import TypeAlias

from ..base import Model
Expand Down Expand Up @@ -44,6 +44,10 @@ async def create_autogen(cls, model_id: UUID, user_id: UUID, **kwargs: Any) -> s
URL = Annotated[HttpUrl, AfterValidator(lambda x: str(x).rstrip("/"))]


class UrlModel(BaseModel):
url: URL


@register("llm")
class AzureOAI(Model):
model: Annotated[
Expand All @@ -60,7 +64,7 @@ class AzureOAI(Model):

base_url: Annotated[
URL, Field(description="The base URL of the Azure OpenAI API")
] = URL(url="https://api.openai.com/v1")
] = UrlModel(url="https://{your-resource-name}.openai.azure.com").url

api_type: Annotated[
Literal["azure"],
Expand Down
2 changes: 1 addition & 1 deletion tests/studio/models/llms/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_azure_model_schema(self) -> None:
"title": "API Key",
},
"base_url": {
"default": "https://api.openai.com/v1",
"default": "https://{your-resource-name}.openai.azure.com",
"description": "The base URL of the Azure OpenAI API",
"format": "uri",
"maxLength": 2083,
Expand Down

0 comments on commit 0a472ec

Please sign in to comment.