Created
September 27, 2024 23:41
-
-
Save elijahbenizzy/33a43994a44af33e591f6c3361740a39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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