diff --git a/samples/apps/autogen-studio/autogenstudio/database/utils.py b/samples/apps/autogen-studio/autogenstudio/database/utils.py index c14003b414c..8fad11baf51 100644 --- a/samples/apps/autogen-studio/autogenstudio/database/utils.py +++ b/samples/apps/autogen-studio/autogenstudio/database/utils.py @@ -166,6 +166,13 @@ def init_db_samples(dbmanager: Any): user_id="guestuser@gmail.com", api_type="google", ) + + anthropic_claude_model = Model( + model="claude-3-sonnet-20240229", + description="Anthropic's Claude 3 Sonnet model", + user_id="guestuser@gmail.com", + api_type="anthropic", + ) # skills @@ -272,6 +279,7 @@ def init_db_samples(dbmanager: Any): with Session(dbmanager.engine) as session: session.add(zephyr_model) session.add(google_gemini_model) + session.add(anthropic_claude_model) session.add(azure_model) session.add(gpt_4_model) session.add(generate_image_skill) diff --git a/samples/apps/autogen-studio/autogenstudio/datamodel.py b/samples/apps/autogen-studio/autogenstudio/datamodel.py index 3dbd46c357e..4a0a619ca67 100644 --- a/samples/apps/autogen-studio/autogenstudio/datamodel.py +++ b/samples/apps/autogen-studio/autogenstudio/datamodel.py @@ -105,6 +105,7 @@ class ModelTypes(str, Enum): openai = "open_ai" google = "google" azure = "azure" + anthropic = "anthropic" class Model(SQLModel, table=True): @@ -126,6 +127,11 @@ class Model(SQLModel, table=True): api_version: Optional[str] = None description: Optional[str] = None agents: List["Agent"] = Relationship(back_populates="models", link_model=AgentModelLink) + # AWS Configuration + aws_access_key: Optional[str] = None + aws_secret_key: Optional[str] = None + aws_session_token: Optional[str] = None + aws_region: Optional[str] = None class CodeExecutionConfigTypes(str, Enum): diff --git a/samples/apps/autogen-studio/autogenstudio/utils/dbdefaults.json b/samples/apps/autogen-studio/autogenstudio/utils/dbdefaults.json index 7f36325266e..0a5d8a81f23 100644 --- a/samples/apps/autogen-studio/autogenstudio/utils/dbdefaults.json +++ b/samples/apps/autogen-studio/autogenstudio/utils/dbdefaults.json @@ -17,6 +17,15 @@ "api_key": "EMPTY", "base_url": "http://localhost:8000/v1", "description": "Local model example with vLLM server endpoint" + }, + { + "model": "anthropic.claude-3-sonnet-20240229-v1:0", + "api_key": "EMPTY", + "aws_access_key": "EMPTY", + "aws_secret_key": "EMPTY", + "aws_session_token": "EMPTY", + "aws_region": "us-east-1", + "description": "Anthropic model configuration" } ], "agents": [ diff --git a/samples/apps/autogen-studio/autogenstudio/utils/utils.py b/samples/apps/autogen-studio/autogenstudio/utils/utils.py index ed533ec3883..8f9418ca14f 100644 --- a/samples/apps/autogen-studio/autogenstudio/utils/utils.py +++ b/samples/apps/autogen-studio/autogenstudio/utils/utils.py @@ -394,7 +394,12 @@ def sanitize_model(model: Model): """ if isinstance(model, Model): model = model.model_dump() - valid_keys = ["model", "base_url", "api_key", "api_type", "api_version"] + valid_keys = [ + # OpenAI-compatible keys + "model", "base_url", "api_key", "api_type", "api_version", + # AWS keys + "aws_access_key", "aws_secret_key", "aws_session_token", "aws_region" + ] # only add key if value is not None sanitized_model = {k: v for k, v in model.items() if (v is not None and v != "") and k in valid_keys} return sanitized_model diff --git a/samples/apps/autogen-studio/frontend/src/components/types.ts b/samples/apps/autogen-studio/frontend/src/components/types.ts index eba39144602..602f1155800 100644 --- a/samples/apps/autogen-studio/frontend/src/components/types.ts +++ b/samples/apps/autogen-studio/frontend/src/components/types.ts @@ -78,12 +78,17 @@ export interface IModelConfig { api_key?: string; api_version?: string; base_url?: string; - api_type?: "open_ai" | "azure" | "google"; + api_type?: "open_ai" | "azure" | "google" | "anthropic"; user_id?: string; created_at?: string; updated_at?: string; description?: string; id?: number; + /* AWS Configuration */ + aws_access_key?: string; + aws_secret_key?: string; + aws_session_token?: string; + aws_region?: string; } export interface IMetadataFile { diff --git a/samples/apps/autogen-studio/frontend/src/components/utils.ts b/samples/apps/autogen-studio/frontend/src/components/utils.ts index 2264f5c66a2..d6264bcc58a 100644 --- a/samples/apps/autogen-studio/frontend/src/components/utils.ts +++ b/samples/apps/autogen-studio/frontend/src/components/utils.ts @@ -266,6 +266,12 @@ export const sampleModelConfig = (modelType: string = "open_ai") => { description: "Google Gemini Model model", }; + const anthropicConfig: IModelConfig = { + model: "claude-3-sonnet-20240229", + api_type: "anthropic", + description: "Anthropic Claude Model model", + }; + switch (modelType) { case "open_ai": return openaiConfig; @@ -273,6 +279,8 @@ export const sampleModelConfig = (modelType: string = "open_ai") => { return azureConfig; case "google": return googleConfig; + case "anthropic": + return anthropicConfig; default: return openaiConfig; } diff --git a/samples/apps/autogen-studio/frontend/src/components/views/builder/utils/modelconfig.tsx b/samples/apps/autogen-studio/frontend/src/components/views/builder/utils/modelconfig.tsx index 9f9c64500f7..82710acfc02 100644 --- a/samples/apps/autogen-studio/frontend/src/components/views/builder/utils/modelconfig.tsx +++ b/samples/apps/autogen-studio/frontend/src/components/views/builder/utils/modelconfig.tsx @@ -36,6 +36,12 @@ const ModelTypeSelector = ({ description: "Gemini", icon: , }, + { + label: "Anthropic", + value: "anthropic", + description: "Anthropic or Anthropic Bedrock", + icon: , + }, ]; const [selectedType, setSelectedType] = React.useState( @@ -83,6 +89,7 @@ const ModelTypeSelector = ({ "In addition to OpenAI models, You can also use OSS models via tools like Ollama, vLLM, LMStudio etc. that provide OpenAI compatible endpoint.", azure: "Azure OpenAI endpoint", google: "Gemini", + anthropic: "Anthropic models available via Anthropic API or Amazon Bedrock" }; const [selectedHint, setSelectedHint] = React.useState("open_ai"); @@ -215,7 +222,7 @@ const ModelConfigMainView = ({ /> } /> - + {model?.api_type != "anthropic" && ( } /> + )}
)} + {/* AWS Configuration */} + {model?.api_type == "anthropic" ? [ + { + updateModelConfig("aws_access_key", e.target.value); + }} + /> + } + />, + { + updateModelConfig("aws_secret_key", e.target.value); + }} + /> + } + />, + { + updateModelConfig("aws_session_token", e.target.value); + }} + /> + } + />, + { + updateModelConfig("aws_region", e.target.value); + }} + /> + } + /> + ] : null}
diff --git a/samples/apps/autogen-studio/pyproject.toml b/samples/apps/autogen-studio/pyproject.toml index bc8c7864ad6..968549f26a6 100644 --- a/samples/apps/autogen-studio/pyproject.toml +++ b/samples/apps/autogen-studio/pyproject.toml @@ -24,7 +24,8 @@ dependencies = [ "typer", "uvicorn", "arxiv", - "pyautogen[gemini]>=0.2.0", + "pyautogen[anthropic,gemini]>=0.2.0", + "anthropic[bedrock]", "python-dotenv", "websockets", "numpy < 2.0.0",