Why am I gettting this error, __init__() takes 0 p...
# ask-ai
w
Why am I gettting this error, __init__() takes 0 positional arguments but 1 was given. When running on VSCODE?
t
Thanks for reaching out, Arthur. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Could you please share the exact line of code where the error pops up, along with the class definition (including the
__init__
method) of the class you're trying to create? That way, I can better understand what's going on and help you fix it.
w
class TalkingAgent(Agent): def __init__(): super().__init__(instructions="You are a helpful and supportive friend.")
t
Hey! The hiccup is with your
__init__
method — it’s missing the
self
parameter, which Python needs for instance methods in classes. Here’s a quick fix for you:
Copy code
class TalkingAgent(Agent):

    def __init__(self):
        super().__init__(instructions="You are a helpful and supportive friend.")
Just adding
self
as the first parameter in your
__init__
method should do the trick. If you run into any more bumps or have questions, I’m here to help!
w
Even with the self parameter it does not work
t
Hey! Could you let me know the exact error message you’re seeing after adding the
self
parameter? Also, if you don’t mind, could you share the definition of the
Agent
class or any details about its
__init__
method? That way, I can help you better!
w
agent = TalkingAgent() # instaniates an agent, which will be used in the agentsession TypeError: TalkingAgent.__init__() takes 0 positional arguments but 1 was given
t
It looks like the error is telling us that the
__init__
method of
TalkingAgent
isn’t quite set up right to accept the implicit
self
parameter. To get this sorted, please double-check that your class definition looks like this:
Copy code
class TalkingAgent(Agent):

    def __init__(self):
        super().__init__(instructions="You are a helpful and supportive friend.")
If you’ve already got it like that, the hiccup might be coming from the parent class
Agent
. Specifically, its
__init__
method might not be set up to accept the
instructions
argument. Could you take a quick look and confirm if the
Agent
class has an
__init__
method that takes
instructions
as a parameter?