Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Using chat completions in Python

This sample demonstrates how to use chat history with the chat completion service to generate a chat-like interface with Azure OpenAI in Semantic Kernel.

System requirements

Setting up the virtual environment

This sample uses a virtual environment to manage dependencies. To set up the virtual environment, run the following commands:

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

For Windows users, the commands are slightly different:

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt

Running the sample

Make sure to deploy GPT-4o in your Azure OpenAI resource and name the deployment gpt-4o. Next, create a new file named .env in the root directory of the sample and add the following variables:

Variable Description
APP_DEPLOYMENT_NAME The name of the deployment
APP_API_KEY The API key of your Azure OpenAI resource
APP_ENDPOINT The endpoint of your Azure OpenAI resource

You can find a sample .env file in the .env.example file.

To run the sample, execute the following command:

python main.py