01 Semantic Kernel
Semantic Kernel
In this code sample, you will use the Semantic Kernel AI Framework to create a basic agent.
The goal of this sample is to show you the steps that we will later use in the additional code samples when implementing the different agentic patterns.
Import the Needed Python Packages
Creating the Client
In this sample, we will use GitHub Models for access to the LLM.
The ai_model_id is defined as gpt-4o-mini. Try changing the model to another model available on the GitHub Models marketplace to see the different results.
For us to use the Azure Inference SDK that is used for the base_url for GitHub Models, we will use the OpenAIChatCompletion connector within Semantic Kernel. There are also other available connectors to use Semantic Kernel for other model providers.
Creating the Agent
Below we create the Agent called TravelAgent.
For this example, we are using very simple instructions. You can change these instructions to see how the agent responds differently.
Running the Agent
Now we can run the Agent by defining a thread of type ChatHistoryAgentThread. Any required system messages are provided to the agent's invoke_stream messages keyword argument.
After these are defined, we create a user_inputs that will be what the user is sending to the agent. In this case, we have set this message to Plan me a sunny vacation.
Feel free to change this message to see how the agent responds differently.