lexlepty/functioncall
0
1import json2 3FUNCTIONS = [4 {5 "name": "search_duckduckgo",6 "description": "使用DuckDuckGo搜索引擎查询信息。可以搜索最新新闻、文章、博客等内容。",7 "parameters": {8 "type": "object",9 "properties": {10 "keywords": {11 "type": "array",12 "items": {"type": "string"},13 "description": "搜索的关键词列表。例如:['Python', '机器学习', '最新进展']。"14 }15 },16 "required": ["keywords"]17 }18 },19 {20 "name": "search_papers",21 "description": "使用Crossref API搜索学术论文。",22 "parameters": {23 "type": "object",24 "properties": {25 "query": {26 "type": "string",27 "description": "搜索查询字符串。例如:'climate change'。"28 }29 },30 "required": ["query"]31 }32 },33 {34 "name": "send_email",35 "description": "发送电子邮件。",36 "parameters": {37 "type": "object",38 "properties": {39 "to": {40 "type": "string",41 "description": "收件人邮箱地址"42 },43 "subject": {44 "type": "string",45 "description": "邮件主题"46 },47 "content": {48 "type": "string",49 "description": "邮件内容"50 }51 },52 "required": ["to", "subject", "content"]53 }54 }55]56 57FUNCTIONS_GROUP_1 = [FUNCTIONS[0], FUNCTIONS[1]] # search_duckduckgo, search_papers58FUNCTIONS_GROUP_2 = [FUNCTIONS[2]] # send_email59 60def get_function_descriptions(functions):61 return [{"name": f["name"], "description": f["description"]} for f in functions]