xiaozhi-esp32-server/xiaozhi-memory/llm/base.py
mkp 0b4d5f594a feat: add LLM memory extraction functionality with OpenAI support
- Implemented a new test script for LLM memory extraction in `test_llm_extraction.py`.
- Created LLM client module with base class `LLMClient` and OpenAI-specific implementation.
- Added fact extraction prompt template for structured memory extraction.
- Integrated memory management with retrieval and intention extraction capabilities.
2026-05-27 22:35:08 +08:00

31 lines
819 B
Python

"""
LLM 客户端基类
"""
from abc import ABC, abstractmethod
from typing import List, Dict, Any
class LLMClient(ABC):
"""LLM 客户端基类"""
@abstractmethod
async def extract_facts(
self,
conversation: str,
context: Dict[str, Any]
) -> List[Dict[str, Any]]:
"""
从对话中提取事实
Args:
conversation: 对话文本
context: 上下文信息
- current_date: 当前日期
- observation_date: 观察日期(用于解析相对时间)
- recently_extracted: 最近提取的记忆(用于去重)
- existing_memories: 现有相关记忆
Returns:
[{"content": "...", "type": "FACT|INTENTION|PREFERENCE", ...}]
"""
pass