长期记忆抽取

更新时间:

kv抽取

HTTP接口

shell

curl --location 'https://nlp.aliyuncs.com/v2/api/extract/kv' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-extract-memory-kv' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
    "messages": [
        {
            "content": "我喜欢打武术",
            "role": "user"
        },
        {
            "content": "那很好,武术不仅是一种技艺,更是一种修身养性的方式。",
            "role": "assistant"
        }
    ],
    "kvMemoryConfigs": [
        {
            "memoryText": "职业"
        },
        {
            "memoryText": "喜欢"
        },
        {
            "memoryText": "名字"
        }
    ]
}'

python

import json

import requests

api_key = "your-api-key"
service_name = "aca-chat-reminder"

url = "https://nlp.aliyuncs.com/v2/api/extract/kv"
headers = {
    "Content-Type": "application/json",
    "x-fag-servicename": "aca-extract-memory-kv",
    "x-fag-appcode": "aca",
    "Authorization": f"Bearer {api_key}"
}

payload = {
    "messages": [
        {
            "content": "我喜欢打武术",
            "role": "user"
        },
        {
            "content": "那很好,武术不仅是一种技艺,更是一种修身养性的方式。",
            "role": "assistant"
        }
    ],
    "kvMemoryConfigs": [
        {
            "memoryText": "职业"
        },
        {
            "memoryText": "喜欢"
        },
        {
            "memoryText": "名字"
        }
    ]
}

response = requests.post(url, headers=headers, json=payload)

print(response.status_code)
print(json.loads(response.text))

summary抽取

HTTP接口

shell

curl --location 'https://nlp.aliyuncs.com/v2/api/extract/summary' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-extract-memory-summary' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
    "messages": [
        {
            "role": "user",
            "content": "你好"
        },
        {
            "role": "assistant",
            "content": "你好呀,今天天气真好"
        },
        {
            "role": "user",
            "content": "我们一起去打篮球把"
        },
        {
            "role": "assistant",
            "content": "好的呀,那我们一起去打球吧,打完篮球我们去吃火锅"
        }
    ]
}'

python

import json

import requests

api_key = "your-api-key"
service_name = "aca-chat-reminder"

url = "https://nlp.aliyuncs.com/v2/api/extract/summary"
headers = {
    "Content-Type": "application/json",
    "x-fag-servicename": "aca-extract-memory-summary",
    "x-fag-appcode": "aca",
    "Authorization": f"Bearer {api_key}"
}

payload = {
    "messages": [
        {
            "role": "user",
            "content": "你好"
        },
        {
            "role": "assistant",
            "content": "你好呀,今天天气真好"
        },
        {
            "role": "user",
            "content": "我们一起去打篮球把"
        },
        {
            "role": "assistant",
            "content": "好的呀,那我们一起去打球吧,打完篮球我们去吃火锅"
        }
    ]
}

response = requests.post(url, headers=headers, json=payload)

print(response.status_code)
print(json.loads(response.text))