#community-help

Resolving TypeError in Python Client for Synonyms Call

TLDR Albert was getting a TypeError when trying to call "synonyms" in the Python client. Jason provided correct syntax and an example, resolving the issue.

Powered by Struct AI
8
28mo
Solved
Join the chat
Jul 22, 2021 (28 months ago)
Albert
Photo of md5-36037a403466e2aeef5e87704f92ab6a
Albert
07:18 PM
👋 Hi everyone! I am getting a error of
TypeError("'Synonyms' object is not callable") 

when I do something like this
client.collections[args.name].synonyms().upsert('smart-phone-synonyms', synonym)

Can someone help?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:55 PM
Albert I'm guessing this is the JS client?

If so, the syntax is:
07:55
Jason
07:55 PM
client.collections(args.name).synonyms().upsert('smart-phone-synonyms', synonym)
Albert
Photo of md5-36037a403466e2aeef5e87704f92ab6a
Albert
08:17 PM
It is a python client, I did the follow and it worked. don't know if it is right.
client.collections(args.name).synonyms.upsert('smart-phone-synonyms', synonym)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:20 PM
Ah yes, it's () for the Python client as well
Albert
Photo of md5-36037a403466e2aeef5e87704f92ab6a
Albert
08:23 PM
that didn't work, i get the error TypeError("'Synonyms' object is not callable")
08:43
Jason
08:43 PM
It's synonyms. not synonyms().