StarCoderBase results in HuggingChat vs API

Hello,

Iā€™m trying to generate Python code using the StarCoderBase model. I get decent results via HuggingChat and the results there are pretty decent.

Hereā€™s my code:

from huggingface_hub.inference_api import InferenceApi

import os
from dotenv import load_dotenv

load_dotenv()
hfkey = os.getenv("HUGGING_FACE_API_KEY")

inference = InferenceApi(repo_id="bigcode/starcoderbase", token=hfkey)

x = inference(inputs="I have a pandas dataframe, df, with 'latitude' and 'longitude' columns. Please provide an algorithm to cluster these points.")
print(x)

Hereā€™s my result:

[{'generated_text': "I have a pandas dataframe, df, with 'latitude' and 'longitude' columns. Please provide an algorithm to cluster these points.\n\n# +\n# Your code here\n# -\n\n# ## 2.2"}]

When I submit the same request (i.e., ā€œI have a pandas dataframe, df, with ā€˜latitudeā€™ and ā€˜longitudeā€™ columns. Please provide an algorithm to cluster these points.ā€) to HuggingChat, I get a much better response: HuggingChat

Could someone let me know what Iā€™m doing wrong? I thought the results would be similar via these two approaches.

Thanks,
Wojciech