Question About Function Calling

Hi everyone,

Based on PEP8 standards, function names should follow “snake_case”. Does anyone know why in the OpenAI documentation in the Function Calling section, the functions follow “camelCase”? For example, they have “getCurrentWeather” as a function tool.

I would appreciate it if someone could please elaborate on that. I wonder why that code is not Pythonic, and if/when we should be doing the same. Thank you.

Hi! Welcome to the forum!

Note that this is an HTTP api - not everyone uses python or thinks adhering to pythonic standards is a good idea.

You’re obviously free to use snake_case!


One thing I would add…

If all or even most of the fine-tuning for function calling was done using functions with camelCase naming conventions, there does exist the possibility that the models would be more successful with calling functions if your functions were also named with camelCase.

Note: I’m not saying this is the case, just making an observation. It may be worthwhile at some point to do some sort of eval to determine if the naming convention used for function calling has any effect on function performance.


This is a pretty interesting point, but I think this should be negligible, and become more negligible as models improve :thinking:

My understanding of the attention mechanism would indicate that in this instance (function calling) you’re asking for an extremely focused pattern/sequence reproduction. I suspect that unless the model had been fine-tuned to expliticly transform or screw up the function names (or snake case in general) it wouldn’t do it on its own :thinking:


Absolutely. I doubt it would have much impact, but I’ve seen stranger and less intuitive behaviours from LLMs before.

I’ve also found it’s much easier to meet the models where they are, rather than trying to force them into my mold.

For instance, I primarily code in R. Preferred R style is to not use explicit return() calls at the end of a function, but rather let the result of the final statement be the return value.

Bad R code (which is the bulk of R code in the internet since there are so few R-first programmers out there) would look something like this,

two_x <- function(x) {
  return(2 * x)

While good R code would look like this,

two_x <- function(x) {
  2 * x

While it’s absolutely possible to force the model to not use The return() function, it requires a lot of the model’s attention mechanism and usually results in poorer quality code on average.

So, I meet the model where it is, let it use whatever style it wants and fix it after the fact.

I can imagine function calling could be similarly affected if the models were trained overwhelmingly with one naming convention. I doubt they were, but I have no inside knowledge about this and this is why I think it might be worthwhile to explore, even if just to eliminate it as a concern.

Anything to make the model’s job easier!