Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Theia AI] Tool Calling with OpenAI API Bug/Improvement: Ensure each function has a clear schema #14663

Open
elementary-particle opened this issue Dec 22, 2024 · 0 comments

Comments

@elementary-particle
Copy link

Handling of functions with no parameters in Theia

Right now the function schema passed to OpenAI APIs and other AI interfaces for getWorkspaceDirectoryStructure does not contain a parameter field. According to standard practice, all function calls by the language models must include a argument object which could contain no argument fields if the arguments are empty. However, it's still necessary to provide the correct parameter object schema in the tool calling request in order to trigger the correct generation behavior in LLMs. E.g. if the parameter field doesn't exist, many models won't be able to generate correct arguments and lead to a chain of problems.

Examples in Theia

Right now the schema for getWorkspaceDirectoryStructure is

{
  "type": "function",
  "function": {
    "name": "getWorkspaceDirectoryStructure",
    "description": "Retrieve the complete directory structure of the workspace, listing only directories (no file contents). This structure excludes specific directories,\n            such as node_modules and hidden files, ensuring paths are within workspace boundaries."
  }
}

This should be amended to something like

{
  "type": "function",
  "function": {
    "name": "getWorkspaceDirectoryStructure",
    "description": "Retrieve the complete directory structure of the workspace, listing only directories (no file contents). This structure excludes specific directories,\n            such as node_modules and hidden files, ensuring paths are within workspace boundaries."
  },
  "parameters": {
    "type": "object",
    "properties": {}
  }
}

A few notes on tool calling templates in Theia

Another problem worth noting is the inclusion of predefined function calls in chat templates. Currently it's impossible to control the exact description of each function in the prompt, and you must include the variables for them to be added to the call. This is quite inflexible, in the case for example when the user wants to provide custom introductions/usage prompts to these functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant