Skip to content

support for azure openai #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion examples/data-analysis/fastagent.config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default_model: sonnet
default_model: azure-gpt-4o

# on windows, adjust the mount point to be the full path e.g. x:/temp/data-analysis/mount-point:/mnt/data/

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/researcher/fastagent.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Examples in comments below - check/change the paths.
#
#

default_model: azure-gpt-4o
execution_engine: asyncio
logger:
type: console
Expand Down
2 changes: 1 addition & 1 deletion examples/workflows/fastagent.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Examples in comments below - check/change the paths.
#
#

default_model: azure-gpt-4o
execution_engine: asyncio
logger:
type: file
Expand Down
2 changes: 1 addition & 1 deletion fastagent.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Examples in comments below - check/change the paths.
#
#

default_model: azure-gpt-4o
execution_engine: asyncio
logger:
type: file
Expand Down
68 changes: 67 additions & 1 deletion schema/mcp-agent.config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,60 @@
"title": "OpenAISettings",
"type": "object"
},
"AzureOpenAISettings": {
"additionalProperties": true,
"description": "Settings for using AzureOpenAI models in the fast-agent application.",
"properties": {
"api_key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Api Key"
},
"reasoning_effort": {
"default": "medium",
"enum": [
"low",
"medium",
"high"
],
"title": "Reasoning Effort",
"type": "string"
},
"base_url": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Base Url"
},
"api_version": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "API Version"
}
},
"title": "OpenAISettings",
"type": "object"
},
"OpenTelemetrySettings": {
"description": "OTEL settings for the fast-agent application.",
"properties": {
Expand Down Expand Up @@ -663,7 +717,7 @@
"type": "null"
}
],
"default": "haiku",
"default": "azure-gpt-4o",
"title": "Default Model"
},
"temporal": {
Expand Down Expand Up @@ -722,6 +776,18 @@
"default": null,
"description": "Settings for using OpenAI models in the fast-agent application"
},
"azureopenai": {
"anyOf": [
{
"$ref": "#/$defs/AzureOpenAISettings"
},
{
"type": "null"
}
],
"default": null,
"description": "Settings for using AzureOpenAI models in the fast-agent application"
},
"deepseek": {
"anyOf": [
{
Expand Down
11 changes: 8 additions & 3 deletions src/mcp_agent/cli/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
# Accepts aliases for Anthropic Models: haiku, haiku3, sonnet, sonnet35, opus, opus3
# and OpenAI Models: gpt-4o-mini, gpt-4o, o1, o1-mini, o3-mini
#
# If not specified, defaults to "haiku".
# If not specified, defaults to "azure-gpt-4o".
# Can be overriden with a command line switch --model=<model>, or within the Agent constructor.

default_model: haiku
# default_model: gpt-4o
default_model: azure-gpt-4o

# Logging and Console Configuration:
logger:
Expand Down Expand Up @@ -59,6 +60,10 @@

openai:
api_key: <your-api-key-here>
azureopenai:
api_key: <your-api-key-here>
base_url: <your-azure-openai-endpoint-here>
api_version: <your-azure-openai-api-version-here>
anthropic:
api_key: <your-api-key-here>

Expand Down Expand Up @@ -215,7 +220,7 @@ def init(
if "fastagent.secrets.yaml" in created:
console.print("\n[yellow]Important:[/yellow] Remember to:")
console.print(
"1. Add your API keys to fastagent.secrets.yaml or set OPENAI_API_KEY and ANTHROPIC_API_KEY environment variables"
"1. Add your API keys to fastagent.secrets.yaml or set OPENAI_API_KEY, AZURE_OPENAI_KEY and ANTHROPIC_API_KEY environment variables"
)
console.print(
"2. Keep fastagent.secrets.yaml secure and never commit it to version control"
Expand Down
34 changes: 33 additions & 1 deletion src/mcp_agent/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ class AnthropicSettings(BaseModel):

model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)

# class BedrockAnthropicSettings(BaseModel):
# """
# Settings for using Anthropic models in the fast-agent application.
# """

# aws_access_key: str | None = None
# aws_secret_key: str | None = None
# # aws_session_token: str | None = None

# base_url: str | None = None

# model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)


class OpenAISettings(BaseModel):
"""
Expand All @@ -125,6 +138,19 @@ class OpenAISettings(BaseModel):

model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)

class AzureOpenAISettings(BaseModel):
"""
Settings for using Azure OpenAI models in the MCP Agent application.
"""

api_key: str | None = None
reasoning_effort: Literal["low", "medium", "high"] = "medium"

base_url: str | None = None
api_version: str | None = None


model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)

class DeepSeekSettings(BaseModel):
"""
Expand Down Expand Up @@ -256,7 +282,7 @@ class Settings(BaseSettings):
execution_engine: Literal["asyncio", "temporal"] = "asyncio"
"""Execution engine for the fast-agent application"""

default_model: str | None = "haiku"
default_model: str | None = "azure-gpt-4o"
"""
Default model for agents. Format is provider.model_name.<reasoning_effort>, for example openai.o3-mini.low
Aliases are provided for common models e.g. sonnet, haiku, gpt-4o, o3-mini etc.
Expand All @@ -267,12 +293,18 @@ class Settings(BaseSettings):
anthropic: AnthropicSettings | None = None
"""Settings for using Anthropic models in the fast-agent application"""

# bedrockanthropic: BedrockAnthropicSettings | None = None
# """Settings for using Anthropic models in the fast-agent application"""

otel: OpenTelemetrySettings | None = OpenTelemetrySettings()
"""OpenTelemetry logging settings for the fast-agent application"""

openai: OpenAISettings | None = None
"""Settings for using OpenAI models in the fast-agent application"""

azureopenai: AzureOpenAISettings | None = None
"""Settings for using Azure OpenAI models in the MCP Agent application"""

deepseek: DeepSeekSettings | None = None
"""Settings for using DeepSeek models in the fast-agent application"""

Expand Down
28 changes: 27 additions & 1 deletion src/mcp_agent/llm/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
from mcp_agent.llm.augmented_llm_passthrough import PassthroughLLM
from mcp_agent.llm.augmented_llm_playback import PlaybackLLM
from mcp_agent.llm.providers.augmented_llm_anthropic import AnthropicAugmentedLLM
# from mcp_agent.llm.providers.augmented_llm_bedrockanthropic import BedrockAnthropicAugmentedLLM
from mcp_agent.llm.providers.augmented_llm_deepseek import DeepSeekAugmentedLLM
from mcp_agent.llm.providers.augmented_llm_generic import GenericAugmentedLLM
from mcp_agent.llm.providers.augmented_llm_openai import OpenAIAugmentedLLM
from mcp_agent.llm.providers.augmented_llm_azureopenai import AzureOpenAIAugmentedLLM
from mcp_agent.llm.providers.augmented_llm_openrouter import OpenRouterAugmentedLLM
from mcp_agent.mcp.interfaces import AugmentedLLMProtocol

Expand All @@ -20,7 +22,9 @@
# Type alias for LLM classes
LLMClass = Union[
Type[AnthropicAugmentedLLM],
# Type[BedrockAnthropicAugmentedLLM],
Type[OpenAIAugmentedLLM],
Type[AzureOpenAIAugmentedLLM],
Type[PassthroughLLM],
Type[PlaybackLLM],
Type[DeepSeekAugmentedLLM],
Expand All @@ -32,7 +36,9 @@ class Provider(Enum):
"""Supported LLM providers"""

ANTHROPIC = auto()
# BEDROCKANTHROPIC = auto()
OPENAI = auto()
AZUREOPENAI = auto()
FAST_AGENT = auto()
DEEPSEEK = auto()
GENERIC = auto()
Expand Down Expand Up @@ -62,7 +68,9 @@ class ModelFactory:
# Mapping of provider strings to enum values
PROVIDER_MAP = {
"anthropic": Provider.ANTHROPIC,
# "bedrockanthropic": Provider.BEDROCKANTHROPIC,
"openai": Provider.OPENAI,
"azureopenai": Provider.AZUREOPENAI,
"fast-agent": Provider.FAST_AGENT,
"deepseek": Provider.DEEPSEEK,
"generic": Provider.GENERIC,
Expand All @@ -89,6 +97,12 @@ class ModelFactory:
"o1": Provider.OPENAI,
"o1-preview": Provider.OPENAI,
"o3-mini": Provider.OPENAI,
"azure-gpt-4o": Provider.AZUREOPENAI,
"azure-gpt-4o-mini": Provider.AZUREOPENAI,
"azure-o1-mini": Provider.AZUREOPENAI,
"azure-o1": Provider.AZUREOPENAI,
"azure-o1-preview": Provider.AZUREOPENAI,
"azure-o3-mini": Provider.AZUREOPENAI,
"claude-3-haiku-20240307": Provider.ANTHROPIC,
"claude-3-5-haiku-20241022": Provider.ANTHROPIC,
"claude-3-5-haiku-latest": Provider.ANTHROPIC,
Expand All @@ -99,6 +113,16 @@ class ModelFactory:
"claude-3-7-sonnet-latest": Provider.ANTHROPIC,
"claude-3-opus-20240229": Provider.ANTHROPIC,
"claude-3-opus-latest": Provider.ANTHROPIC,
# "anthropic.claude-3-haiku-20240307-v1:0": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-5-haiku-20241022-v1:0": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-5-haiku-latest": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-5-sonnet-20240620-v1:0": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-5-sonnet-20241022-v2:0": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-5-sonnet-latest": Provider.BEDROCKANTHROPIC,
# "us.anthropic.claude-3-7-sonnet-20250219-v1:0": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-7-sonnet-latest": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-opus-20240229": Provider.BEDROCKANTHROPIC,
# "anthropic.claude-3-opus-latest": Provider.BEDROCKANTHROPIC,
"deepseek-chat": Provider.DEEPSEEK,
# "deepseek-reasoner": Provider.DEEPSEEK, reinstate on release
}
Expand All @@ -119,8 +143,10 @@ class ModelFactory:

# Mapping of providers to their LLM classes
PROVIDER_CLASSES: Dict[Provider, LLMClass] = {
Provider.ANTHROPIC: AnthropicAugmentedLLM,
# Provider.ANTHROPIC: AnthropicAugmentedLLM,
# Provider.BEDROCKANTHROPIC: BedrockAnthropicAugmentedLLM,
Provider.OPENAI: OpenAIAugmentedLLM,
Provider.AZUREOPENAI: AzureOpenAIAugmentedLLM,
Provider.FAST_AGENT: PassthroughLLM,
Provider.DEEPSEEK: DeepSeekAugmentedLLM,
Provider.GENERIC: GenericAugmentedLLM,
Expand Down
Loading
Loading