更新时间:2024-08-29 GMT+08:00
多轮对话
支持上下文记忆的多轮对话。
- 初始化
from pangukitsappdev.skill.conversation_skill import ConversationSkill from pangukitsappdev.api.llms.factory import LLMs skill = ConversationSkill(LLMs.of("pangu"))
- 问答
from pangukitsappdev.memory.redis_message_history import RedisMessageHistory from langchain.memory import ConversationBufferWindowMemory # 定义存储策略 skill.set_memory(ConversationBufferWindowMemory(k=3, chat_memory=RedisMessageHistory())) answer = skill.execute("中国首都是哪个城市?") print(answer) assert "北京" in answer answer = skill.execute("它有什么好玩的地方?") print(answer) assert "故宫" in answer
父主题: Skill(技能)