Welcome to Magnus Liber Imperatorum, the Great Book of Roman Emperors.
Magnus Liber is an Azure OpenAI demo of the chat completion APIs written in different programming languages. The goal of the demos is to illustrate basic use of the OpenAI chat completion API, including request parameters, response and conversation management.
To run Magnus Liber in any programming language, an Azure Subscription and an Azure OpenAI deployment will be necessary.
- If necessary, get a free Azure subscription.
- Create an Azure OpenAI service resource.
- Deploy either an OpenAI
gpt-4
orgpt-3-turbo
model. (Other models do not support chat completions and will not work) - Open a terminal
- Run
git clone https://github.com/jfbilodeau/MagnusLiber.git
- Run
cd MagnusLiber
- Enter the directory of the demo you wish to run and review the instructions in
README.md
. All demos will require that the following environment variables be set:OPENAI_URL
OPENAI_KEY
OPENAI_DEPLOYMENT
- Consistent functionality across demos
- Idiomatic code
- Minimize local dependencies
- Favour Azure OpenAI SDK when available
- For simplicity, written as one function
- For clarity, there is very little error handling
The following prompts can be used to demonstrates different aspect of Azure OpenAI chat completion.
-
Demonstrate the use of the
system
message by using the following prompts:Who are you?
What can you do?
-
Demonstrate conversation state by using the following prompts in sequence:
Who was the first emperor?
Who followed him?
-
Demonstrate optional counting as defined in the
system
message by using the following prompt:Who were the five great emperors?
-
Demonstrate the
max_token
parameter by reducing it from1500
to150
and re-run the above prompt. The answer will exceen the value ofmax_token
and will be truncated. -
Demonstrate the ability of OpenAI to understand different languages:
What does your name mean?
Quis fuit primus Romanorum imperator?
('Who was the first Roman Emperor' in Latin)
-
To get a answer in Latin, try:
Quis es tu?
(Who are you?)
-
Type
exit
orquit
to terminal the demo.CTRL+C
works as well.