Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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.
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.
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.
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.
164 changes: 84 additions & 80 deletions translations/de/00-course-setup/README.md

Large diffs are not rendered by default.

120 changes: 67 additions & 53 deletions translations/de/01-intro-to-ai-agents/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Semantischer Kernel\n",
"\n",
"In diesem Codebeispiel verwenden Sie das [Semantic Kernel](https://aka.ms/ai-agents-beginners/semantic-kernel) AI-Framework, um einen einfachen Agenten zu erstellen.\n",
"\n",
"Das Ziel dieses Beispiels ist es, Ihnen die Schritte zu zeigen, die wir später in den zusätzlichen Codebeispielen verwenden werden, wenn wir die verschiedenen agentischen Muster implementieren.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Importieren Sie die benötigten Python-Pakete\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os \n",
"from typing import Annotated\n",
"from openai import AsyncOpenAI\n",
"\n",
"from dotenv import load_dotenv\n",
"\n",
"from semantic_kernel.agents import ChatCompletionAgent, ChatHistoryAgentThread\n",
"from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion\n",
"from semantic_kernel.functions import kernel_function"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Erstellen des Clients\n",
"\n",
"In diesem Beispiel verwenden wir [GitHub Models](https://aka.ms/ai-agents-beginners/github-models) für den Zugriff auf das LLM.\n",
"\n",
"Die `ai_model_id` ist als `gpt-4o-mini` definiert. Versuchen Sie, das Modell auf ein anderes Modell aus dem GitHub Models-Marktplatz zu ändern, um die unterschiedlichen Ergebnisse zu sehen.\n",
"\n",
"Um das `Azure Inference SDK` zu nutzen, das für die `base_url` von GitHub Models verwendet wird, verwenden wir den `OpenAIChatCompletion`-Connector innerhalb von Semantic Kernel. Es gibt auch andere [verfügbare Connectoren](https://learn.microsoft.com/semantic-kernel/concepts/ai-services/chat-completion), um Semantic Kernel mit anderen Modellanbietern zu verwenden.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random \n",
"\n",
"# Define a sample plugin for the sample\n",
"\n",
"class DestinationsPlugin:\n",
" \"\"\"A List of Random Destinations for a vacation.\"\"\"\n",
"\n",
" def __init__(self):\n",
" # List of vacation destinations\n",
" self.destinations = [\n",
" \"Barcelona, Spain\",\n",
" \"Paris, France\",\n",
" \"Berlin, Germany\",\n",
" \"Tokyo, Japan\",\n",
" \"Sydney, Australia\",\n",
" \"New York, USA\",\n",
" \"Cairo, Egypt\",\n",
" \"Cape Town, South Africa\",\n",
" \"Rio de Janeiro, Brazil\",\n",
" \"Bali, Indonesia\"\n",
" ]\n",
" # Track last destination to avoid repeats\n",
" self.last_destination = None\n",
"\n",
" @kernel_function(description=\"Provides a random vacation destination.\")\n",
" def get_random_destination(self) -> Annotated[str, \"Returns a random vacation destination.\"]:\n",
" # Get available destinations (excluding last one if possible)\n",
" available_destinations = self.destinations.copy()\n",
" if self.last_destination and len(available_destinations) > 1:\n",
" available_destinations.remove(self.last_destination)\n",
"\n",
" # Select a random destination\n",
" destination = random.choice(available_destinations)\n",
"\n",
" # Update the last destination\n",
" self.last_destination = destination\n",
"\n",
" return destination"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"load_dotenv()\n",
"client = AsyncOpenAI(\n",
" api_key=os.environ.get(\"GITHUB_TOKEN\"), \n",
" base_url=\"https://models.inference.ai.azure.com/\",\n",
")\n",
"\n",
"# Create an AI Service that will be used by the `ChatCompletionAgent`\n",
"chat_completion_service = OpenAIChatCompletion(\n",
" ai_model_id=\"gpt-4o-mini\",\n",
" async_client=client,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Erstellen des Agenten\n",
"\n",
"Im Folgenden erstellen wir den Agenten namens `TravelAgent`.\n",
"\n",
"Für dieses Beispiel verwenden wir sehr einfache Anweisungen. Sie können diese Anweisungen ändern, um zu sehen, wie der Agent unterschiedlich reagiert.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"agent = ChatCompletionAgent(\n",
" service=chat_completion_service, \n",
" plugins=[DestinationsPlugin()],\n",
" name=\"TravelAgent\",\n",
" instructions=\"You are a helpful AI Agent that can help plan vacations for customers at random destinations\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Den Agenten ausführen\n",
"\n",
"Nun können wir den Agenten ausführen, indem wir einen Thread vom Typ `ChatHistoryAgentThread` definieren. Alle erforderlichen Systemnachrichten werden dem `messages` Schlüsselwortargument von `invoke_stream` des Agenten übergeben.\n",
"\n",
"Nachdem diese definiert wurden, erstellen wir ein `user_inputs`, das die Nachricht enthält, die der Benutzer an den Agenten sendet. In diesem Fall haben wir diese Nachricht auf `Plan me a sunny vacation` gesetzt.\n",
"\n",
"Du kannst diese Nachricht gerne ändern, um zu sehen, wie der Agent unterschiedlich darauf reagiert.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"async def main():\n",
" # Create a new thread for the agent\n",
" # If no thread is provided, a new thread will be\n",
" # created and returned with the initial response\n",
" thread: ChatHistoryAgentThread | None = None\n",
"\n",
" user_inputs = [\n",
" \"Plan me a day trip.\",\n",
" ]\n",
"\n",
" for user_input in user_inputs:\n",
" print(f\"# User: {user_input}\\n\")\n",
" first_chunk = True\n",
" async for response in agent.invoke_stream(\n",
" messages=user_input, thread=thread,\n",
" ):\n",
" # 5. Print the response\n",
" if first_chunk:\n",
" print(f\"# {response.name}: \", end=\"\", flush=True)\n",
" first_chunk = False\n",
" print(f\"{response}\", end=\"\", flush=True)\n",
" thread = response.thread\n",
" print()\n",
"\n",
" # Clean up the thread\n",
" await thread.delete() if thread else None\n",
"\n",
"await main()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n---\n\n**Haftungsausschluss**: \nDieses Dokument wurde mit dem KI-Übersetzungsdienst [Co-op Translator](https://github.com/Azure/co-op-translator) übersetzt. Obwohl wir uns um Genauigkeit bemühen, beachten Sie bitte, dass automatisierte Übersetzungen Fehler oder Ungenauigkeiten enthalten können. Das Originaldokument in seiner ursprünglichen Sprache sollte als maßgebliche Quelle betrachtet werden. Für kritische Informationen wird eine professionelle menschliche Übersetzung empfohlen. Wir übernehmen keine Haftung für Missverständnisse oder Fehlinterpretationen, die sich aus der Nutzung dieser Übersetzung ergeben.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv (3.12.11)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.11"
},
"coopTranslator": {
"original_hash": "9faeec13969c8dff8a53f0933771d228",
"translation_date": "2025-08-30T10:54:29+00:00",
"source_file": "01-intro-to-ai-agents/code_samples/01-semantic-kernel.ipynb",
"language_code": "de"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading