Skip to main content

Reference implementation of CogProfile — the AI cognitive identity standard

Project description

CogProfile Python SDK

把对话记忆变成持续进化的认知身份证。

CogProfile 是一个开放标准,定义了 AI 系统如何表达对一个人的理解。本仓库是它的 Python 参考实现。

和现有工具的区别

Mem0、Memobase 做的是记忆存储——记住用户说了什么。

CogProfile 做的是认知建模——理解用户说的这些话意味着什么。

Mem0/Memobase 输出:
  用户是程序员,喜欢咖啡,在北京工作

CogProfile 输出:
  用户是程序员,但最近三周5次提到想转产品经理
  情绪持续两周下滑(0.7 → 0.3),主要触发因素是工作压力
  和上级关系恶化中(3个月内从正面转向负面)
  行为规律:提到加班后2天内会聊美食(出现3次)
  学日语的目标40天未提及,可能已放弃

安装

pip install cogprofile

快速开始

import asyncio
from datetime import datetime, timedelta
from cogprofile import CogProfileEngine, Memory

engine = CogProfileEngine(
    llm_api_key="sk-xxx",
    llm_provider="deepseek",  # 也支持 dashscope / moonshot / zhipu / openai
)

memories = [
    Memory(id="1", user_id="u1", content="新项目开始了,很兴奋",
           created_at=datetime.now() - timedelta(days=14)),
    Memory(id="2", user_id="u1", content="连续加班一周,感觉很疲惫",
           created_at=datetime.now() - timedelta(days=2)),
]

async def main():
    profile = await engine.update(user_id="u1", memories=memories)

    print(profile.emotion.current.label)       # "stressed"
    print(profile.emotion.trend.direction)      # "declining"
    print(profile.goals.fading)                 # 正在放弃的目标列表

asyncio.run(main())

对接已有记忆系统

Mem0

from mem0 import Memory as Mem0Memory
from cogprofile import CogProfileEngine
from cogprofile.storage import Mem0Adapter

mem0 = Mem0Memory()
store = Mem0Adapter(mem0_client=mem0)
engine = CogProfileEngine(llm_api_key="sk-xxx", store=store)

profile = await engine.update(user_id="user_001")

自定义数据库

from cogprofile.storage import MemoryStore

class MyStore(MemoryStore):
    async def get_memories(self, user_id, since=None, until=None, category=None, limit=500):
        rows = await my_db.query(...)
        return [Memory(...) for row in rows]

    async def get_all_users(self):
        return await my_db.query("SELECT DISTINCT user_id FROM memories")

认知身份证包含什么

模块 内容 示例
身份 静态事实和偏好 姓名、职业、饮食偏好
情绪 情感状态和变化轨迹 "压力持续两周上升,触发因素是工作"
注意力 话题焦点和异常 "工作压力最近7天提了8次,异常升温"
目标 计划和承诺追踪 "学日语:提了3次,然后40天没再提"
关系 关键人物和关系动态 "对李经理的态度连续3个月恶化"
模式 行为规律 "提到加班后2天内会聊美食"
预测 前瞻推断 "可能1-2周内提出离职"

支持的大模型

提供商 provider 值 默认模型
DeepSeek deepseek deepseek-chat
阿里通义 dashscope qwen-plus
Moonshot moonshot moonshot-v1-8k
智谱AI zhipu glm-4-flash
OpenAI openai gpt-4o-mini

规范

完整的 CogProfile 数据格式定义见:cogprofile-spec

许可证

Apache 2.0

引用

@misc{cogprofile2026,
  title={CogProfile: An Open Standard for AI Cognitive Identity},
  author={CogProfile Project},
  year={2026},
  url={https://github.com/cogprofile/cogprofile-spec}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cogprofile-0.1.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cogprofile-0.1.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file cogprofile-0.1.0.tar.gz.

File metadata

  • Download URL: cogprofile-0.1.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cogprofile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0969e6594dd6cccf7037826f12649b1142f565c119c6e5d086aa77763cd8f16a
MD5 b1fa4896c2223dfda3caba90e79e189e
BLAKE2b-256 ed690848addbf290207e7c633e64bcf3e12ab47fa45ca7a927abb0d402f3274c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cogprofile-0.1.0.tar.gz:

Publisher: publish.yml on cogprofile/cogprofile-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cogprofile-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cogprofile-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cogprofile-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a80088eb4bac7be9b0df1d9aa865cf220f01f75ef010e3672b94e9f6583add8c
MD5 6034ccd4ff943298e01bedbbfb48eb80
BLAKE2b-256 42c7613c6b9093442287c7d73b7ac77d99c4229cbf8a90d17bd54c036e0899d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cogprofile-0.1.0-py3-none-any.whl:

Publisher: publish.yml on cogprofile/cogprofile-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page