Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/python-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ env:
GOOGLE_AI_GEMINI_MODEL_ID: ${{ vars.GOOGLE_AI_GEMINI_MODEL_ID }}
GOOGLE_AI_EMBEDDING_MODEL_ID: ${{ vars.GOOGLE_AI_EMBEDDING_MODEL_ID }}
GOOGLE_AI_API_KEY: ${{ secrets.GOOGLE_AI_API_KEY }}
GOOGLE_AI_CLOUD_PROJECT_ID: ${{ vars.GOOGLE_AI_CLOUD_PROJECT_ID }}
VERTEX_AI_PROJECT_ID: ${{ vars.VERTEX_AI_PROJECT_ID }}
VERTEX_AI_GEMINI_MODEL_ID: ${{ vars.VERTEX_AI_GEMINI_MODEL_ID }}
VERTEX_AI_EMBEDDING_MODEL_ID: ${{ vars.VERTEX_AI_EMBEDDING_MODEL_ID }}
Expand Down
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Highlights
- Flexible Agent Framework: build, orchestrate, and deploy AI agents and multi-agent systems
- Multi-Agent Systems: Model workflows and collaboration between AI specialists
- Plugin Ecosystem: Extend with Python, OpenAPI, Model Context Protocol (MCP), and more
- LLM Support: OpenAI, Azure OpenAI, Hugging Face, Mistral, Vertex AI, ONNX, Ollama, NVIDIA NIM, and others
- LLM Support: OpenAI, Azure OpenAI, Hugging Face, Mistral, Google AI, ONNX, Ollama, NVIDIA NIM, and others
- Vector DB Support: Azure AI Search, Elasticsearch, Chroma, and more
- Process Framework: Build structured business processes with workflow modeling
- Multimodal: Text, vision, audio
Expand Down
4 changes: 2 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
]
dependencies = [
# azure agents
"azure-ai-projects >= 1.0.0b12",
"azure-ai-projects ~= 1.0.0b12",
"azure-ai-agents >= 1.2.0b3",
"aiohttp ~= 3.8",
"cloudevents ~=1.0",
Expand Down Expand Up @@ -93,7 +93,7 @@ faiss = [
]
google = [
"google-cloud-aiplatform ~= 1.114.0",
"google-generativeai ~= 0.8"
"google-genai ~= 1.51.0"
]
hugging_face = [
"transformers[torch] ~= 4.28",
Expand Down
18 changes: 5 additions & 13 deletions python/samples/concepts/plugins/plugins_from_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,21 @@
import asyncio
import os

from azure.identity import AzureCliCredential

from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import AzureTextCompletion, OpenAITextCompletion
from semantic_kernel.connectors.ai.open_ai import OpenAITextCompletion
from semantic_kernel.functions import KernelArguments


async def main():
kernel = Kernel()

useAzureOpenAI = False
model = "gpt-35-turbo-instruct" if useAzureOpenAI else "gpt-3.5-turbo-instruct"
model = "gpt-3.5-turbo-instruct"
service_id = model

# Configure AI service used by the kernel
if useAzureOpenAI:
kernel.add_service(
AzureTextCompletion(service_id=service_id, credential=AzureCliCredential()),
)
else:
kernel.add_service(
OpenAITextCompletion(service_id=service_id, ai_model_id=model),
)
kernel.add_service(
OpenAITextCompletion(service_id=service_id, ai_model_id=model),
)

# note: using plugins from the samples folder
plugins_directory = os.path.join(__file__, "../../../../../prompt_template_samples/")
Expand Down
7 changes: 3 additions & 4 deletions python/samples/concepts/setup/ALL_SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
| | [OpenAITextToAudio](../../../semantic_kernel/connectors/ai/open_ai/services/open_ai_text_to_audio.py) | ai_model_id, <br> api_key, <br> org_id | OPENAI_TEXT_TO_AUDIO_MODEL_ID, <br> OPENAI_API_KEY, <br> OPENAI_ORG_ID | Yes, <br> Yes, <br> No | |
| | [OpenAIAudioToText](../../../semantic_kernel/connectors/ai/open_ai/services/open_ai_audio_to_text.py) | ai_model_id, <br> api_key, <br> org_id | OPENAI_AUDIO_TO_TEXT_MODEL_ID, <br> OPENAI_API_KEY, <br> OPENAI_ORG_ID | Yes, <br> Yes, <br> No | |
| Azure OpenAI | [AzureChatCompletion](../../../semantic_kernel/connectors/ai/open_ai/services/azure_chat_completion.py) | deployment_name, <br> api_key, <br> endpoint, <br> api_version, <br> base_url | AZURE_OPENAI_CHAT_DEPLOYMENT_NAME, <br> AZURE_OPENAI_API_KEY, <br> AZURE_OPENAI_ENDPOINT, <br> AZURE_OPENAI_API_VERSION, <br> AZURE_OPENAI_BASE_URL | Yes, <br> No, <br> Yes, <br> Yes, <br> Yes | [AzureOpenAISettings](../../../semantic_kernel/connectors/ai/open_ai/settings/azure_open_ai_settings.py) |
| | [AzureTextCompletion](../../../semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py) | deployment_name, <br> api_key, <br> endpoint, <br> api_version, <br> base_url | AZURE_OPENAI_TEXT_DEPLOYMENT_NAME, <br> AZURE_OPENAI_API_KEY, <br> AZURE_OPENAI_ENDPOINT, <br> AZURE_OPENAI_API_VERSION, <br> AZURE_OPENAI_BASE_URL | Yes, <br> No, <br> Yes, <br> Yes, <br> Yes | |
| | [AzureTextEmbedding](../../../semantic_kernel/connectors/ai/open_ai/services/azure_text_embedding.py) | deployment_name, <br> api_key, <br> endpoint, <br> api_version, <br> base_url | AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME, <br> AZURE_OPENAI_API_KEY, <br> AZURE_OPENAI_ENDPOINT, <br> AZURE_OPENAI_API_VERSION, <br> AZURE_OPENAI_BASE_URL | Yes, <br> No, <br> Yes, <br> Yes, <br> Yes | |
| | [AzureTextToImage](../../../semantic_kernel/connectors/ai/open_ai/services/azure_text_to_image.py) | deployment_name, <br> api_key, <br> endpoint | AZURE_OPENAI_TEXT_TO_IMAGE_DEPLOYMENT_NAME, <br> AZURE_OPENAI_API_KEY, <br> AZURE_OPENAI_ENDPOINT | Yes, <br> No, <br> Yes | |
| | [AzureTextToAudio](../../../semantic_kernel/connectors/ai/open_ai/services/azure_text_to_audio.py) | deployment_name, <br> api_key, <br> endpoint | AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME, <br> AZURE_OPENAI_API_KEY, <br> AZURE_OPENAI_ENDPOINT | Yes, <br> No, <br> Yes | |
Expand All @@ -25,9 +24,9 @@
| Google AI | [GoogleAIChatCompletion](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py) | gemini_model_id, <br> api_key | GOOGLE_AI_GEMINI_MODEL_ID, <br> GOOGLE_AI_API_KEY | Yes, <br> Yes | [GoogleAISettings](../../../semantic_kernel/connectors/ai/google/google_ai/google_ai_settings.py) |
| | [GoogleAITextCompletion](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_completion.py) | gemini_model_id, <br> api_key | GOOGLE_AI_GEMINI_MODEL_ID, <br> GOOGLE_AI_API_KEY | Yes, <br> Yes | |
| | [GoogleAITextEmbedding](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_embedding.py) | embedding_model_id, <br> api_key | GOOGLE_AI_EMBEDDING_MODEL_ID, <br> GOOGLE_AI_API_KEY | Yes, <br> Yes | |
| Vertex AI | [VertexAIChatCompletion](../../../semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_chat_completion.py) | project_id, <br> region, <br> gemini_model_id | VERTEX_AI_PROJECT_ID, <br> VERTEX_AI_REGION, <br> VERTEX_AI_GEMINI_MODEL_ID | Yes, <br> No, <br> Yes | [VertexAISettings](../../../semantic_kernel/connectors/ai/google/vertex_ai/vertex_ai_settings.py) |
| | [VertexAITextCompletion](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_completion.py) | project_id, <br> region, <br> gemini_model_id | VERTEX_AI_PROJECT_ID, <br> VERTEX_AI_REGION, <br> VERTEX_AI_GEMINI_MODEL_ID | Yes, <br> No, <br> Yes | |
| | [VertexAITextEmbedding](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_embedding.py) | project_id, <br> region, <br> embedding_model_id | VERTEX_AI_PROJECT_ID, <br> VERTEX_AI_REGION, <br> VERTEX_AI_EMBEDDING_MODEL_ID | Yes, <br> No, <br> Yes | |
| Vertex AI | [GoogleAIChatCompletion](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py) | project_id, <br> region, <br> gemini_model_id | GOOGLE_AI_CLOUD_PROJECT_ID, <br> GOOGLE_AI_CLOUD_REGION, <br> GOOGLE_AI_GEMINI_MODEL_ID, <br> GOOGLE_AI_USE_VERTEXAI | Yes, <br> No, <br> Yes, <br> Yes (must set to true) | [GoogleAISettings](../../../semantic_kernel/connectors/ai/google/google_ai/google_ai_settings.py) |
| | [GoogleAITextCompletion](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_completion.py) | project_id, <br> region, <br> gemini_model_id | GOOGLE_AI_CLOUD_PROJECT_ID, <br> GOOGLE_AI_CLOUD_REGION, <br> GOOGLE_AI_GEMINI_MODEL_ID, <br> GOOGLE_AI_USE_VERTEXAI | Yes, <br> No, <br> Yes, <br> Yes (must set to true) | |
| | [GoogleAITextEmbedding](../../../semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_embedding.py) | project_id, <br> region, <br> embedding_model_id | GOOGLE_AI_CLOUD_PROJECT_ID, <br> GOOGLE_AI_CLOUD_REGION, <br> GOOGLE_AI_EMBEDDING_MODEL_ID, <br> GOOGLE_AI_USE_VERTEXAI | Yes, <br> No, <br> Yes, <br> Yes (must set to true) | |
| HuggingFace | [HuggingFaceTextCompletion](../../../semantic_kernel/connectors/ai/hugging_face/services/hf_text_completion.py) | ai_model_id | N/A | Yes | |
| | [HuggingFaceTextEmbedding](../../../semantic_kernel/connectors/ai/hugging_face/services/hf_text_embedding.py) | ai_model_id | N/A | Yes | |
| NVIDIA NIM | [NvidiaChatCompletion](../../../semantic_kernel/connectors/ai/nvidia/services/nvidia_chat_completion.py) | ai_model_id, <br> api_key, <br> base_url | NVIDIA_CHAT_MODEL_ID, <br> NVIDIA_API_KEY, <br> NVIDIA_BASE_URL | Yes (default: meta/llama-3.1-8b-instruct), <br> Yes, <br> No | [NvidiaAISettings](../../../semantic_kernel/connectors/ai/nvidia/settings/nvidia_settings.py) |
Expand Down
14 changes: 4 additions & 10 deletions python/samples/concepts/setup/chat_completion_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,7 @@ def get_google_ai_chat_completion_service_and_request_settings() -> tuple[
Please refer to the Semantic Kernel Python documentation for more information:
https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel
"""
from semantic_kernel.connectors.ai.google.google_ai import (
GoogleAIChatCompletion,
GoogleAIChatPromptExecutionSettings,
)
from semantic_kernel.connectors.ai.google import GoogleAIChatCompletion, GoogleAIChatPromptExecutionSettings

chat_service = GoogleAIChatCompletion(service_id=service_id)
request_settings = GoogleAIChatPromptExecutionSettings(service_id=service_id)
Expand Down Expand Up @@ -356,13 +353,10 @@ def get_vertex_ai_chat_completion_service_and_request_settings() -> tuple[
Please refer to the Semantic Kernel Python documentation for more information:
https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel
"""
from semantic_kernel.connectors.ai.google.vertex_ai import (
VertexAIChatCompletion,
VertexAIChatPromptExecutionSettings,
)
from semantic_kernel.connectors.ai.google import GoogleAIChatCompletion, GoogleAIChatPromptExecutionSettings

chat_service = VertexAIChatCompletion(service_id=service_id)
request_settings = VertexAIChatPromptExecutionSettings(service_id=service_id)
chat_service = GoogleAIChatCompletion(service_id=service_id, use_vertexai=True)
request_settings = GoogleAIChatPromptExecutionSettings(service_id=service_id)

return chat_service, request_settings

Expand Down
37 changes: 3 additions & 34 deletions python/samples/concepts/setup/text_completion_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Services(str, Enum):
"""

OPENAI = "openai"
AZURE_OPENAI = "azure_openai"
BEDROCK = "bedrock"
GOOGLE_AI = "google_ai"
HUGGING_FACE = "huggingface"
Expand All @@ -36,7 +35,6 @@ def get_text_completion_service_and_request_settings(
# Use lambdas or functions to delay instantiation
text_services = {
Services.OPENAI: lambda: get_openai_text_completion_service_and_request_settings(),
Services.AZURE_OPENAI: lambda: get_azure_openai_text_completion_service_and_request_settings(),
Services.BEDROCK: lambda: get_bedrock_text_completion_service_and_request_settings(),
Services.GOOGLE_AI: lambda: get_google_ai_text_completion_service_and_request_settings(),
Services.HUGGING_FACE: lambda: get_hugging_face_text_completion_service_and_request_settings(),
Expand Down Expand Up @@ -75,32 +73,6 @@ def get_openai_text_completion_service_and_request_settings() -> tuple[
return text_service, request_settings


def get_azure_openai_text_completion_service_and_request_settings() -> tuple[
"TextCompletionClientBase", "PromptExecutionSettings"
]:
"""Return Azure OpenAI text completion service and request settings.

The service credentials can be read by 3 ways:
1. Via the constructor
2. Via the environment variables
3. Via an environment file

The request settings control the behavior of the service. The default settings are sufficient to get started.
However, you can adjust the settings to suit your needs.
Note: Some of the settings are NOT meant to be set by the user.
Please refer to the Semantic Kernel Python documentation for more information:
https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel
"""
from azure.identity import AzureCliCredential

from semantic_kernel.connectors.ai.open_ai import AzureTextCompletion, OpenAITextPromptExecutionSettings

text_service = AzureTextCompletion(credential=AzureCliCredential())
request_settings = OpenAITextPromptExecutionSettings()

return text_service, request_settings


def get_bedrock_text_completion_service_and_request_settings() -> tuple[
"TextCompletionClientBase", "PromptExecutionSettings"
]:
Expand Down Expand Up @@ -262,12 +234,9 @@ def get_vertex_ai_text_completion_service_and_request_settings() -> tuple[
Please refer to the Semantic Kernel Python documentation for more information:
https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel
"""
from semantic_kernel.connectors.ai.google.vertex_ai import (
VertexAITextCompletion,
VertexAITextPromptExecutionSettings,
)
from semantic_kernel.connectors.ai.google import GoogleAITextCompletion, GoogleAITextPromptExecutionSettings

text_service = VertexAITextCompletion()
request_settings = VertexAITextPromptExecutionSettings()
text_service = GoogleAITextCompletion()
request_settings = GoogleAITextPromptExecutionSettings()

return text_service, request_settings
9 changes: 3 additions & 6 deletions python/samples/concepts/setup/text_embedding_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,10 @@ def get_vertex_ai_text_embedding_service_and_request_settings() -> tuple[
Please refer to the Semantic Kernel Python documentation for more information:
https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel
"""
from semantic_kernel.connectors.ai.google.vertex_ai import (
VertexAIEmbeddingPromptExecutionSettings,
VertexAITextEmbedding,
)
from semantic_kernel.connectors.ai.google import GoogleAIEmbeddingPromptExecutionSettings, GoogleAITextEmbedding

embedding_service = VertexAITextEmbedding()
embedding_service = GoogleAITextEmbedding()
# Note: not all models support specifying the dimensions or there may be constraints on the dimensions
request_settings = VertexAIEmbeddingPromptExecutionSettings(output_dimensionality=768)
request_settings = GoogleAIEmbeddingPromptExecutionSettings(output_dimensionality=768)

return embedding_service, request_settings
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

# You can select from the following text embedding services:
# - Services.OPENAI
# - Services.AZURE_OPENAI
# - Services.BEDROCK
# - Services.GOOGLE_AI
# - Services.HUGGING_FACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

# You can select from the following text embedding services:
# - Services.OPENAI
# - Services.AZURE_OPENAI
# - Services.BEDROCK
# - Services.GOOGLE_AI
# - Services.HUGGING_FACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,8 @@
"source": [
"from services import Service\n",
"\n",
"from samples.service_settings import ServiceSettings\n",
"\n",
"service_settings = ServiceSettings()\n",
"\n",
"# Select a service to use for this notebook (available services: OpenAI, AzureOpenAI, HuggingFace)\n",
"selectedService = (\n",
" Service.AzureOpenAI\n",
" if service_settings.global_llm_service is None\n",
" else Service(service_settings.global_llm_service.lower())\n",
")\n",
"selectedService = Service.OpenAI\n",
"print(f\"Using service type: {selectedService}\")"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,8 @@
"source": [
"from services import Service\n",
"\n",
"from samples.service_settings import ServiceSettings\n",
"\n",
"service_settings = ServiceSettings()\n",
"\n",
"# Select a service to use for this notebook (available services: OpenAI, AzureOpenAI, HuggingFace)\n",
"selectedService = (\n",
" Service.AzureOpenAI\n",
" if service_settings.global_llm_service is None\n",
" else Service(service_settings.global_llm_service.lower())\n",
")\n",
"selectedService = Service.OpenAI\n",
"print(f\"Using service type: {selectedService}\")"
]
},
Expand Down
7 changes: 3 additions & 4 deletions python/semantic_kernel/connectors/ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ All base clients inherit from the [`AIServiceClientBase`](../../services/ai_serv
| | [`OpenAITextToAudio`](./open_ai/services/open_ai_text_to_audio.py) |
| | [`OpenAIAudioToText`](./open_ai/services/open_ai_audio_to_text.py) |
| Azure OpenAI | [`AzureChatCompletion`](./open_ai/services/azure_chat_completion.py) |
| | [`AzureTextCompletion`](./open_ai/services/azure_text_completion.py) |
| | [`AzureTextEmbedding`](./open_ai/services/azure_text_embedding.py) |
| | [`AzureTextToImage`](./open_ai/services/azure_text_to_image.py) |
| | [`AzureTextToAudio`](./open_ai/services/azure_text_to_audio.py) |
Expand All @@ -38,9 +37,9 @@ All base clients inherit from the [`AIServiceClientBase`](../../services/ai_serv
| [Google AI](./google/README.md) | [`GoogleAIChatCompletion`](./google/google_ai/services/google_ai_chat_completion.py) |
| | [`GoogleAITextCompletion`](./google/google_ai/services/google_ai_text_completion.py) |
| | [`GoogleAITextEmbedding`](./google/google_ai/services/google_ai_text_embedding.py) |
| [Vertex AI](./google/README.md) | [`VertexAIChatCompletion`](./google/vertex_ai/services/vertex_ai_chat_completion.py) |
| | [`VertexAITextCompletion`](./google/vertex_ai/services/vertex_ai_text_completion.py) |
| | [`VertexAITextEmbedding`](./google/vertex_ai/services/vertex_ai_text_embedding.py) |
| [Vertex AI](./google/README.md) | [`GoogleAIChatCompletion`](./google/google_ai/services/google_ai_chat_completion.py) |
| | [`GoogleAITextCompletion`](./google/google_ai/services/google_ai_text_completion.py) |
| | [`GoogleAITextEmbedding`](./google/google_ai/services/google_ai_text_embedding.py) |
| HuggingFace | [`HuggingFaceTextCompletion`](./hugging_face/services/hf_text_completion.py) |
| | [`HuggingFaceTextEmbedding`](./hugging_face/services/hf_text_embedding.py) |
| Mistral AI | [`MistralAIChatCompletion`](./mistral_ai/services/mistral_ai_chat_completion.py) |
Expand Down
10 changes: 6 additions & 4 deletions python/semantic_kernel/connectors/ai/google/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Once you have an API key, you can start using Gemini models in SK using the `goo
kernel = Kernel()
kernel.add_service(
GoogleAIChatCompletion(
gemini_model_id="gemini-1.5-flash",
gemini_model_id="gemini-2.5-flash",
api_key="...",
)
)
Expand All @@ -39,9 +39,11 @@ Once you have your project and your environment is set up, you can start using G
```Python
kernel = Kernel()
kernel.add_service(
VertexAIChatCompletion(
GoogleAIChatCompletion(
project_id="...",
gemini_model_id="gemini-1.5-flash",
region="...",
gemini_model_id="gemini-2.5-flash",
use_vertexai=True,
)
)
...
Expand All @@ -51,4 +53,4 @@ kernel.add_service(

## Why is there code that looks almost identical in the implementations on the two connectors

The two connectors have very similar implementations, including the utils files. However, they are fundamentally different as they depend on different packages from Google. Although the namings of many types are identical, they are different types.
The two connectors have very similar implementations, including the utils files. However, they are fundamentally different as they depend on different packages from Google. Although the namings of many types are identical, they are different types.
Loading
Loading