courses icon indicating copy to clipboard operation
courses copied to clipboard

Typo: Remove Unnecessary `f` Format String Literal

Open ryanoneill opened this issue 8 months ago • 1 comments

This commit removes an unnecessary Python f format string literal in the "02 Messages Format" lesson of the "API Fundamentals" course. It is used twice for the prompt which asks Claude to "Generate a beautiful haiku", however no Python variables are present within the prompt, and so the f is not needed.

ryanoneill avatar Mar 28 '25 20:03 ryanoneill

Testing done:

❯ uv run ipython
Python 3.12.8 (main, Jan 14 2025, 22:49:14) [Clang 19.1.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.0.2 -- An enhanced Interactive Python. Type '?' for help.
Tip: You can use `files = !ls *.png`

In [1]: from dotenv import load_dotenv

In [2]: load_dotenv()
Out[2]: True

In [3]: from anthropic import Client

In [4]: client = Client()

In [5]: response = client.messages.create(
   ...:     model="claude-3-haiku-20240307",
   ...:     max_tokens=500,
   ...:     messages=[
   ...:         {"role": "user", "content": "Ge
      ⋮ nerate a beautiful haiku"},
   ...:         {"role": "assistant", "content"
      ⋮ : "calming mountain air"}
   ...:     ]
   ...: )
   ...: print(response.content[0].text)
,
gentle breeze, blooming flowers sway,
peaceful solitude.

ryanoneill avatar Mar 28 '25 20:03 ryanoneill