By frank.bailey.jr ·August 7, 2026· 4 min read
Task 1 of KodeKloud's ๐๐ - ๐๐ฒ๐๐ฒ๐น ๐ญ curriculum
Task ๐ญ of KodeKloud's ๐๐ - ๐๐ฒ๐๐ฒ๐น ๐ญ curriculum. This curriculum focuses on tasks related to AI and AI code development. Today's task was to create a script that will take a bug report and rewrite it in a clear, structured, and professional issue summary.
Here were the task requirements:
โข Initialize the OpenAI client using environment values (api_key and base_url).
โข Define a function ๐ฐ๐น๐ฎ๐ฟ๐ถ๐ณ๐_๐ฏ๐๐ด(๐ฑ๐ฒ๐๐ฐ๐ฟ๐ถ๐ฝ๐๐ถ๐ผ๐ป: ๐๐๐ฟ) -> ๐๐๐ฟ that builds a parameterized prompt to rewrite the raw bug description.
โข Send this prompt to the OpenAI Chat Completion API.
โข Use the following configuration for the API call:
model: openai/gpt-4.1-mini
messages: user โ the constructed prompt
max_tokens: 100
temperature: 0.0
โข Use the input bug report: "App keeps crashing when I click save."
โข Store the AI response in a variable named ๐ฟ๐ฒ๐๐ฝ๐ผ๐ป๐๐ฒ and print the clarified bug summary to the console.
โข Function must use the developer's input description dynamically in the prompt.
โข OpenAI credentials are stored as ENV variables
These were a lot of requirements, though it's not as difficult as it sounds. If you want to see how this completed, please review the screenshot of my script that I have included. Here are some things to pay attention to:
- I added comments on each section for clarification on what is happening and matching up with the task requirements
- I didn't hard-code ANY api keys or base_urls. This is for 2 reasons, security and to make this modularized. This allows ANYONE to run this script with their own OpenAI credentials
- I used the OpenAI library, not LangChain. This was due to the task requirements
I hope you found this informative! More to come!Task ๐ญ of KodeKloud's ๐๐ - ๐๐ฒ๐๐ฒ๐น ๐ญ curriculum. This curriculum focuses on tasks related to AI and AI code development. Today's task was to create a script that will take a bug report and rewrite it in a clear, structured, and professional issue summary.
Here were the task requirements:
โข Initialize the OpenAI client using environment values (api_key and base_url).
โข Define a function ๐ฐ๐น๐ฎ๐ฟ๐ถ๐ณ๐_๐ฏ๐๐ด(๐ฑ๐ฒ๐๐ฐ๐ฟ๐ถ๐ฝ๐๐ถ๐ผ๐ป: ๐๐๐ฟ) -> ๐๐๐ฟ that builds a parameterized prompt to rewrite the raw bug description.
โข Send this prompt to the OpenAI Chat Completion API.
โข Use the following configuration for the API call:
model: openai/gpt-4.1-mini
messages: user โ the constructed prompt
max_tokens: 100
temperature: 0.0
โข Use the input bug report: "App keeps crashing when I click save."
โข Store the AI response in a variable named ๐ฟ๐ฒ๐๐ฝ๐ผ๐ป๐๐ฒ and print the clarified bug summary to the console.
โข Function must use the developer's input description dynamically in the prompt.
โข OpenAI credentials are stored as ENV variables
These were a lot of requirements, though it's not as difficult as it sounds. If you want to see how this completed, please review the script that I have included. Here are some things to pay attention to:
- I added comments on each section for clarification on what is happening and matching up with the task requirements
- I didn't hard-code ANY api keys or base_urls. This is for 2 reasons, security and to make this modularized. This allows ANYONE to run this script with their own OpenAI credentials
- I used the OpenAI library, not LangChain. This was due to the task requirements
from openai import OpenAI
# declaring the OpenAI client and passing explicitly the api_key and base_url
# the values are passed from the ENV keys found in /root/.bash_profile
client = OpenAI(
base_url=os.environ.get("OPENAI_API_BASE"),
api_key=os.environ.get("OPENAI_API_KEY")
)
# defining clarify_bug with a description parameter for input bug report
def clarify_bug(description: str) -> str:
# declaring model, max_tokens, and temperature
response = client.chat.completions.create(
model="openai/gpt-4.1-mini",
messages=[
{
"role": "system",
"content": "You are a helpful, articulate software engineer. Please give clear, structured, professional summaries."
},
{
"role": "user",
"content": f"Please rewrite the raw bug description: {description}."
}
],
temperature=0.0,
max_tokens=100
)
# Extract and return the response text
return response.choices[0].message.content
# declaring main
def main():
input_test_report = "App keeps crashing when I click save."
# as per the requirement, storing reponse as a response variable
response = clarify_bug(input_test_report)
if response:
# print the response
print(response)
else:
print("Failed to retrieve response from LLM")
if __name__ == "__main__":
main()
I hope you found this informative! More to come!