Skip to content

Instantly share code, notes, and snippets.

@elijahbenizzy
Created September 27, 2024 23:41
Show Gist options
  • Save elijahbenizzy/33a43994a44af33e591f6c3361740a39 to your computer and use it in GitHub Desktop.
Save elijahbenizzy/33a43994a44af33e591f6c3361740a39 to your computer and use it in GitHub Desktop.
TYPE_MAP = {
str: "string",
int: "integer",
float: "number",
bool: "boolean",
}
OPENAI_TOOLS = [
{
"type": "function",
"function": {
"name": fn_name,
"description": fn.__doc__ or fn_name,
"parameters": {
"type": "object",
"properties": {
param.name: {
"type": TYPE_MAP[param.annotation], # Validation of signatures not shown
"description": param.name,
}
for param in inspect.signature(fn).parameters.values()
},
"required": [param.name for param in inspect.signature(fn).parameters.values()],
},
},
}
for fn_name, fn in {
"query_weather": _weather_tool,
"order_coffee": _order_coffee_tool,
"text_wife": _text_wife_tool,
"fallback": _fallback,
}.items()
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment