L5-tools-routing-apis-student, self.wiki, erroneous code?

Hi,

In the search_wikipedia method pasted below - is it that the method has been refactored and the self.wiki_client references are accidentally still there?

The @tool should return a callable, thus no reference to self should be possible?

image

1 Like

Hi Adam,

I concur that the lines of code within the ‘except’ block are indeed erroneous. It’s important to note that OpenAI Functions do not require the actual execution of the function for it to be considered valid. They only need the function definitions to be present. Therefore, in this particular example, there’s no necessity to iterate with the ‘for loop’ and enter the ‘try-except’ block, which allows for a proper result to be returned without triggering an error—even with the flawed portion included.

The problematic lines that include ‘self’ seem to be taken from a method within a class that presumably interacts with the Wikipedia API. Those lines should not be present outside of their class definition, as ‘self’ references an instance of the class that is not available in the current context.

1 Like