-
Book Overview & Buying
-
Table Of Contents
Supercharged Coding with GenAI
By :
In Lab 2.2, we will expand on our basic OpenAI API request to the Chat service by adding additional parameters to customize the model’s response. This time, we will ask the Chat service to explain the Two Sum problem, a topic we will explore further in later chapters.
We will use a similar starter code from Lab 2.1, which includes setting up an OpenAI client and print statements:
client: OpenAI = OpenAI()
completion: openai.ChatCompletion = (
client.chat.completions.create())
print("Completion Tokens: ")
print("Output: ")
In this lab’s guided walk-through, we will add the following payload parameters:
n: Specifies the number of response variations
temperature: Controls the level of randomness in the model’s output ranging from 0 to 2
max_tokens: Limits the number of tokens in each response
Applications such as code completion services often offer users multiple...