Lab 2.3 – using OpenAI API to generate code
Now that we have learned how to execute OpenAI API calls and configure various parameters, we can use them to create our own basic code completion program. Previously, developers could select models such as code-davinci-002, which were specifically trained for code completion. These models have since been deprecated and now chat services can effectively handle code completion tasks.
Routing chat capabilities to code completion
In this lab, we will create a code completion program by following five steps:
- Define the input to function signatures only.
- Add system prompts to guide the model in generating the complete code.
- Wrap the function signature with a specific instruction for the model to complete the code.
- Get the Chat service response for our request.
- Extract only the code from the model’s output to present to the end user.
These steps demonstrate that applications built...