Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibuildthecloud/30e99f2eee4cbd614b7e469c6e6444b3 to your computer and use it in GitHub Desktop.
Save ibuildthecloud/30e99f2eee4cbd614b7e469c6e6444b3 to your computer and use it in GitHub Desktop.
OpenAI function calling format
The following tools
```json
"tools": [
{
"type": "function",
"function": {
"name": "read",
"description": "Reads the contents of a file",
"parameters": {
"properties": {
"filename": {
"description": "The name of the file to read",
"type": "string"
}
},
"type": "object"
}
}
},
{
"type": "function",
"function": {
"name": "write",
"description": "Write the contents to a file",
"parameters": {
"properties": {
"content": {
"description": "The content to write",
"type": "string"
},
"filename": {
"description": "The name of the file to write to",
"type": "string"
}
},
"type": "object"
}
}
},
{
"type": "function",
"function": {
"name": "chat_finish",
"description": "Concludes the conversation. This can not be used to ask a question.",
"parameters": {
"properties": {
"summary": {
"description": "A summary of the dialog",
"type": "string"
}
},
"type": "object"
}
}
}
]```
get converted tnto the following prompt.
```typescript
## functions
namespace functions {
// Reads the contents of a file
type read = (_: {
// The name of the file to read
filename?: string,
}) => any;
// Write the contents to a file
type write = (_: {
// The content to write
content?: string,
// The name of the file to write to
filename?: string,
}) => any;
// Concludes the conversation. This can not be used to ask a question.
type chat_finish = (_: {
// A summary of the dialog
summary?: string,
}) => any;
} // namespace functions
## multi_tool_use
// This tool serves as a wrapper for utilizing multiple tools. Each tool that can be used must be specified in the tool sections. Only tools in the functions namespace are permitted.
// Ensure that the parameters provided to each tool are valid according to that tool's specification.
namespace multi_tool_use {
// Use this function to run multiple tools simultaneously, but only if they can operate in parallel. Do this even if the prompt suggests using the tools sequentially.
type parallel = (_: {
// The tools to be executed in parallel. NOTE: only functions tools are permitted
tool_uses: {
// The name of the tool to use. The format should either be just the name of the tool, or in the format namespace.function_name for plugin and function tools.
recipient_name: string,
// The parameters to pass to the tool. Ensure these are valid according to the tool's own specifications.
parameters: object,
}[],
}) => any;
} // namespace multi_tool_use
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment