AI -Level 1 - Task4: Perform Comparisons with AI

Hello!

I don´t know if I’m posting in the correct comunity, but I’m taking the AI practice and I’m stucked at the 4th task. The task description is the following:

The xfusion AI Development Team is now exploring how artificial intelligence can assist in making smarter, data-driven decisions for cloud optimization.
Continuing this journey, you are tasked to build a Python-based AI module that compares chipset used between two major iPhone models.

Inside compare.py, create an OpenAI client using the provided api_key and base_url under /root/.bash_profile.

Then, define a function named compare(item1: str, item2: str) → str that constructs a parameterized prompt asking the AI to compare the two given iPhone models (item1 and item2) in terms of only the chip used, ensuring the response is given in one word only.

Use the following items for comparison:

iphone 13
iphone 17

After defining the function, send the constructed prompt to the OpenAI chat model using:
model: openai/gpt-4.1-mini
messages: user → prompt
max_tokens: 100
temperature: 0.5

Store the result in a variable named response, and print the one-word comparison output to the console.

Finally, run your compare.py file to perform the chip comparison.

Notes: Function should accept two parameters: item1 and item2. Use the provided OpenAI api_key and base_url under /root/.bash_profile.

File compare.py must be inside /root/openaiproject.

Use hardcoded values for api_key and base_url when initializing the OpenAI client or read them from environment variables via os.environ.get(‘XXXXX’).

Before running the script run the following python commands to set up the environment and to install the openai:

You are allowed a maximum of 10 requests. After this, you may encounter a rate limiter error, so use your calls wisely.

No matter how I construct the prompt and, following the instructions, printing out a one word response, I’m getting the following task failuer message: “Output should include details for ‘iPhone 13’.”

No matter how I interpret this message, I ssee a conflict between the original instruction “one word only” and the checker feedback “output should include details for iPhone 13.”

Did anyone else faced this issue?

Thanks!

You may want to look at this Medium poster’s pages, since he has solutions for the AI Level 1 labs.

1 Like

Thank you Rob!

But still, the solution “explained” over there still doesn’t resolve my doubts. Maybe my English knowladge are not up to the understandig, How come the possible anwer to this request " asking the AI to compare the two given iPhone models (item1 and item2) in terms of only the chip used, ensuring the response is given in one word only." has as posibile solutoin:

Expected Output Example

- **iPhone 13** uses the **A15 Bionic** chipset.
- **iPhone 17** uses the **A17 Pro** chipset.

And I’m informed that I failed the task with the message: “Output should include details for ‘iPhone 13’.”

Any way, I skipped the task, so… so much for that series.

Thanks once again Bob! I’ll take the rest of the information from the indicated link.

Best regards!