Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ GOOGLE_API_KEY="..."
XAI_API_KEY='...'
OPEN_ROUTER_API_KEY='..'

# Azure AI Foundry
# With API key: AZURE_BASE_URL="https://<resource>.services.ai.azure.com/openai/v1"
# With Entra ID: AZURE_BASE_URL="https://<resource>.services.ai.azure.com/api/projects/<project>"
# AZURE_API_KEY="..." # Optional - omit to use DefaultAzureCredential

# EVENTS_OUTPUT_PATH="./events.txt" # Optional - path to output events file
# RESULTS_OUTPUT_PATH="./results.txt" # Optional - path to output results file

Expand Down
2 changes: 1 addition & 1 deletion llm-config.override.template.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Override the LLM config here for the agents.

// Supported providers: openai, google, openrouter, xai, vertexai
// Supported providers: openai, google, openrouter, xai, vertexai, azure
// You can use any model as long as it is supported by the provider.

// Do not modify this file directly, instead copy it to llm.override.jsonc and modify it there.
Expand Down
2 changes: 2 additions & 0 deletions minitap/mobile_use/agents/outputter/test_outputter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
sys.modules["langchain_google_genai"] = Mock()
sys.modules["langchain_openai"] = Mock()
sys.modules["langchain_cerebras"] = Mock()
sys.modules["langchain_azure_ai"] = Mock()
sys.modules["langchain_azure_ai.chat_models"] = Mock()

from minitap.mobile_use.agents.outputter.outputter import outputter # noqa: E402
from minitap.mobile_use.config import LLM, OutputConfig # noqa: E402
Expand Down
8 changes: 7 additions & 1 deletion minitap/mobile_use/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ class Settings(BaseSettings):
GOOGLE_API_KEY: SecretStr | None = None
XAI_API_KEY: SecretStr | None = None
OPEN_ROUTER_API_KEY: SecretStr | None = None
AZURE_API_KEY: SecretStr | None = None
MINITAP_API_KEY: SecretStr | None = None

OPENAI_BASE_URL: str | None = None
AZURE_BASE_URL: str | None = None
MINITAP_BASE_URL: str = "https://platform.minitap.ai"

ADB_HOST: str | None = None
Expand Down Expand Up @@ -94,7 +96,7 @@ def record_events(output_path: Path | None, events: list[str] | BaseModel | Any)

### LLM Configuration

LLMProvider = Literal["openai", "google", "openrouter", "xai", "vertexai", "minitap"]
LLMProvider = Literal["openai", "google", "openrouter", "xai", "vertexai", "minitap", "azure"]
LLMUtilsNode = Literal["outputter", "hopper", "video_analyzer"]
LLMUtilsNodeWithFallback = LLMUtilsNode
AgentNode = Literal[
Expand Down Expand Up @@ -128,6 +130,9 @@ class LLM(BaseModel):

def validate_provider(self, name: str):
match self.provider:
case "azure":
if not settings.AZURE_BASE_URL:
raise Exception(f"{name} requires AZURE_BASE_URL in .env")
case "openai":
if not settings.OPENAI_API_KEY:
raise Exception(f"{name} requires OPENAI_API_KEY in .env")
Expand All @@ -146,6 +151,7 @@ def validate_provider(self, name: str):
if not settings.MINITAP_API_KEY:
raise Exception(f"{name} requires MINITAP_API_KEY in .env")


def __str__(self):
return f"{self.provider}/{self.model}"

Expand Down
28 changes: 28 additions & 0 deletions minitap/mobile_use/services/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any, Literal, TypeVar, overload

from langchain_core.language_models.chat_models import BaseChatModel
from langchain_azure_ai.chat_models import AzureAIOpenAIApiChatModel
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_google_vertexai import ChatVertexAI
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -169,6 +170,31 @@ def get_grok_llm(model_name: str, temperature: float = 1) -> ChatOpenAI:
)
return client

def get_azure_llm(model_name: str, temperature: float = 1) -> AzureAIOpenAIApiChatModel:
assert settings.AZURE_BASE_URL is not None

api_key: str | None = None
if settings.AZURE_API_KEY:
api_key = settings.AZURE_API_KEY.get_secret_value()

if api_key:
client = AzureAIOpenAIApiChatModel(
model=model_name,
endpoint=settings.AZURE_BASE_URL,
credential=api_key,
temperature=temperature,
)
else:
from azure.identity import DefaultAzureCredential

client = AzureAIOpenAIApiChatModel(
model=model_name,
project_endpoint=settings.AZURE_BASE_URL,
credential=DefaultAzureCredential(),
temperature=temperature,
)
return client


@overload
def get_llm(
Expand Down Expand Up @@ -228,6 +254,8 @@ def get_llm(
return get_openrouter_llm(llm.model, temperature)
elif llm.provider == "xai":
return get_grok_llm(llm.model, temperature)
elif llm.provider == "azure":
return get_azure_llm(llm.model, temperature)
elif llm.provider == "minitap":
remote_tracing = False
if ctx.execution_setup:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies = [
"uuid-utils>=0.12.0",
"limrun-api>=0.1.0",
"websockets>=12.0",
"langchain-azure-ai>=1.1.1",
]

[project.optional-dependencies]
Expand Down
Loading