lawyer_assitance / functions /get_pizza_restaurant_menu.py
qgyd2021's picture
[update]add function calling test
83e0115
raw
history blame
No virus
1.7 kB
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import json
from typing import List
def get_pizza_restaurant_menu():
result = """
菜单包括:
菜品:
意式辣香肠披萨(大、中、小) 12.95、10.00、7.00
芝士披萨(大、中、小) 10.95、9.25、6.50
茄子披萨(大、中、小) 11.95、9.75、6.75
薯条(大、小) 4.50、3.50
希腊沙拉 7.25
配料:
奶酪 2.00
蘑菇 1.50
香肠 3.00
加拿大熏肉 3.50
AI酱 1.50
辣椒 1.00
饮料:
可乐(大、中、小) 3.00、2.00、1.00
雪碧(大、中、小) 3.00、2.00、1.00
瓶装水 5.00
"""
return result
def kwargs() -> List[str]:
"""
函数调用时会根据此处返回的 key 来创建 kwargs 关键字参数,如果存在 key 的值没有提供,则会将其赋值为 None。
因此在定义函数时有默认值的参数的值应该为 None,而其真正的默认值可在函数内部赋值,以免被 kwargs 中的 None 覆盖。
"""
return []
def main():
tools = [
{
"type": "function",
"function": {
"name": "get_pizza_restaurant_menu",
"description": "获取披萨餐厅的菜单。",
"parameters": {
"type": "object",
"properties": {},
"required": [],
},
},
}
]
tools_ = json.dumps(tools, ensure_ascii=False)
print(tools_)
print(tools_.replace("\"", "\\\""))
result = get_pizza_restaurant_menu()
print(result)
return
if __name__ == '__main__':
main()