Help with using transformers agents for sentiment extraction/ summarisation

I am getting an error when using transformer agent.

from transformers import OpenAiAgent
from huggingface_hub import login
from transformers import HfAgent
login("*****")
agent = OpenAiAgent(model="text-davinci-003", api_key="******")
# Starcoder
# agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder")
# StarcoderBase
# agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoderbase")
# OpenAssistant
# agent = HfAgent(url_endpoint="https://api-inference.huggingface.co/models/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5")

agent.run(f"What is the sentiment of the following comment: 'Him saying income is increasing relative to the rise in house prices, both rental and wholesale purchasing of a house? I guess these politicians are really losing their touch with the middle class. Never thought I’d have to consider living overseas once I start work, but here I am. Such a shame'")

Output:

==Explanation from the agent==
I will use the following  tool: `text_classifier` to classify the sentiment of the comment.


==Code generated by the agent==
labels = ["positive", "neutral", "negative"]
sentiment = text_classifier(text=comment, labels=labels)
print(f"The sentiment of the comment is {sentiment}.")


==Result==
Evaluation of the code stopped at line 1 before the end because of the following error:
The variable `comment` is not defined.
['positive', 'neutral', 'negative']

Do I need to preprocess the input? Not sure how to resolve the error and any direction/guidance would be greatly appreciated!

My ultimate goal is to summarise and synthesise ideas from different comments using the transformer agent. I am aware of using OpenAI’s API but I want to explore potentially free options and transformer agents seemed promising. I’d be happy to explore other options if anyone has recommendations as well :smile: