← All posts

By frank.bailey.jr ·August 7, 2026· 4 min read

Task 1 of KodeKloud's ๐—”๐—œ - ๐—Ÿ๐—ฒ๐˜ƒ๐—ฒ๐—น ๐Ÿญ curriculum

aillmopenaimlopskodekloud

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:

  1. I added comments on each section for clarification on what is happening and matching up with the task requirements
  2. 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
  3. 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:

  1. I added comments on each section for clarification on what is happening and matching up with the task requirements
  2. 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
  3. 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!