...
透過以下的 plugin 可以協助 summary 一段文章或者取出文章當中的重點
summaricationsummarization: 透過此 function 可以提供文章的摘要
focal_points: 透過此 function 可以列文章的重點
程式碼區塊 | ||
---|---|---|
| ||
import json from pyodide.http import pyfetch async def main(): response = await chat( conversation=CURRENT_CONVERSATION + [ { "role": "system", "content": "Only use the functions you have been provided with." } ], functions=[ { "name": "summarization", "description": "summarize the conversation", "parameters": { "type": "object", "properties": { "summary": { "type": "string", "description": "the summary of the conversation" } }, "required": ["summary"] } }, { "name": "focal_points", "description": "extract the focal points of the conversation", "parameters": { "type": "object", "properties": { "points": { "type": "array", "items": { "type": "string", "description": "extract the focal points of the conversation" } } }, "required": ["points"] } } ] ) if 'function_call' in response: if response['function_call']['name'] == 'summarization': print("The summary of the converstaion is ", json.loads(response['function_call']['arguments'])['summary']) elif response['function_call']['name'] == 'focal_points': print("The focal points of the converstaion are ", json.loads(response['function_call']['arguments'])['points']) else: print(response['content']) await main() |