
chatmemory使用時の思い出すためのfunction calling
chatmemory使用時の思い出すための、function callingです。
functions = [
# AIが、質問に対してこの関数を使うかどうか、
# また使う時の引数は何にするかを判断するための情報を与える
{
"name": "remember",
"description": "何か思い出す。",
"parameters": {
"type": "object",
"properties": {
# 引数の情報
"what": {
"type": "string",
"description": "何を思い出すか。",
},
"system_content": {
"type": "string",
"description": "システムメッセージの内容。",
},
},
"required": ["what"],
},
}
]
~~ 略 ~~
resp = client.chat.completions.create(
model="gpt-3.5-turbo-1106",
messages=messages,
functions=functions,
function_call="auto",
)
a = resp.choices[0].message.content
if not a:
a = "ふーん。(相づち)"
追記:
def remember(what):
return functions.remember({what: "思い出した方が良いこと。"})