© 2026FindAgent  · @simprr
返回列表
e

emcie-co/parlant

The conversational control layer for customer-facing AI agents - Parlant is a context-engineering framework optimized for controlling customer interactions.

ai-agentsai-alignmentcustomer-servicecustomer-successgeminigenaihacktoberfestllama3llmopenaipython
⭐

17.9k

Stars

🔱

1.5k

Forks

👁

103

Watchers

📋

58

Issues

PythonApache-2.0创建于 2024/2/15更新于 今天
在 GitHub 上查看访问主页
README
由 Gemini 翻译整理

Parlant:面向客户 AI 代理的对话控制层

网站 • 快速入门 • 示例 • Discord

Deutsch | Español | français | 日本語 | 한국어 | Português | Русский | 中文

 

Parlant 简化了企业级 B2C 和敏感 B2B 交互的对话上下文工程,确保交互过程始终保持一致性、合规性并符合品牌调性。

为什么选择 Parlant?

对话上下文工程(Context Engineering)之所以困难,是因为现实世界的交互具有多样性、细微差别和非线性特征。

❌ 问题所在:你可能尝试过但无法在大规模场景下应用的方法

System prompts(系统提示词):在生产环境复杂度增加之前尚可运行。但在提示词中添加的指令越多,代理(Agent)忽略指令的速度就越快。

Routed graphs(路由图):虽然解决了提示词过载的问题,但随着路由逻辑的增加,面对混乱的自然交互时,系统会变得极其脆弱。

🔑 解决方案:专为对话控制优化的上下文工程

Parlant 通过 上下文工程 解决了这一问题:在正确的时间将“不多不少”的正确上下文输入到提示词中。你只需定义一次规则、知识和工具;引擎会实时将上下文缩窄至与当前对话回合最相关的部分。

快速上手

pip install parlant
import parlant.sdk as p

async with p.Server():
    agent = await server.create_agent(
        name="Customer Support",
        description="Handles customer inquiries for an airline",
    )

    # 仅在特定条件下评估并调用工具
    expert_customer = await agent.create_observation(
        condition="customer uses financial terminology like DTI or amortization",
        tools=[research_deep_answer],
    )

    # 当专家观察条件成立时,始终进行深度回复。
    # 设置准则,使其在依赖的观察条件成立时自动匹配...
    expert_answers = await agent.create_guideline(
        matcher=p.MATCH_ALWAYS,
        action="respond with technical depth",
        dependencies=[expert_customer],
    )

    beginner_answers = await agent.create_guideline(
        condition="customer seems new to the topic",
        action="simplify and use concrete examples",
    )

    # 当两者都匹配时,初学者准则生效。
    # 专家级的工具数据和指令都不会进入代理的上下文。
    await beginner_answers.exclude(expert_customer)

按照 5分钟快速入门指南 查看完整流程。

Parlant 概览

你通过代码(而非提示词)定义代理的行为,引擎会在每一轮对话中动态缩窄上下文,只保留最相关的内容,从而确保 LLM 保持专注,代理保持一致。

graph TD
    O[Observations] -->|Events| E[Contextual Matching Engine]
    G[Guidelines] -->|Instructions| E
    J["Journeys (SOPs)"] -->|Current Steps| E
    R[Retrievers] -->|Domain Knowledge| E
    GL[Glossary] -->|Domain Terms| E
    V[Variables] -->|Memories| E
    E -->|Tool Requests| T[Tool Caller]
    T -.->|Results + Optional Extra Matching Iterations| E
    T -->|**Key Result:**Focused Context Window| M[Message Generation]

Parlant 不会向模型发送庞大的系统提示词和原始对话,而是首先组装一个聚焦的上下文——仅匹配与当前对话回合相关的指令和工具——然后基于该缩窄后的上下文生成回复。

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#e8f5e9', 'primaryTextColor': '#1b5e20', 'primaryBorderColor': '#81c784', 'lineColor': '#66bb6a', 'secondaryColor': '#fff9e1', 'tertiaryColor': 'transparent'}}}%%
flowchart LR
    A(User):::outputNode

    subgraph Engine["Parlant Engine"]
        direction LR
        B["Match Guidelines and Resolve Journey States"]:::matchNode
        C["Call Contextually-Associated Tools and Workflows"]:::toolNode
        D["Generated Message"]:::composeNode
        E["Canned Message"]:::cannedNode
    end

    A a@-->|💬 User Input| B
    B b@--> C
    C c@-->|Fluid Output Mode?| D
    C d@-->|Strict Output Mode?| E
    D e@-->|💬 Fluid Output| A
    E f@-->|💬 Canned Output| A

    a@{animate: true}
    b@{animate: true}
    c@{animate: true}
    d@{animate: true}
    e@{animate: true}
    f@{animate: true}

    linkStyle 2 stroke-width:2px
    linkStyle 4 stroke-width:2px
    linkStyle 3 stroke-width:2px,stroke:#3949AB
    linkStyle 5 stroke-width:2px,stroke:#3949AB

    classDef composeNode fill:#F9E9CB,stroke:#AB8139,stroke-width:2px,color:#7E5E1A,stroke-width:0
    classDef cannedNode fill:#DFE3F9,stroke:#3949AB,stroke-width:2px,color:#1a237e,stroke-width:0

通过这种方式,添加更多的规则会让代理变得更聪明,而不是更混乱。

贡献者
mkMMHmAMTP
项目信息
默认分支develop
LicenseApache License 2.0
创建时间2024/2/15
最近更新今天
GAI 中文摘要

Parlant 是一个专为面向客户的 AI 智能体设计的对话控制层框架。该项目通过上下文工程技术,帮助企业构建在处理复杂、多变及高敏感度对话场景时,仍能保持高度一致性、合规性和品牌风格的智能交互系统。

通过上下文管理实现对对话流程的精准控制,有效解决了传统系统提示词在复杂交互中失效的问题。 支持灵活的状态与上下文注入,确保 AI 智能体在面对非线性沟通时依然能够遵循既定业务逻辑。 具备企业级合规与一致性保障能力,确保智能体输出始终符合品牌标准与服务规范。 兼容多种主流大模型,支持开发者利用现有的 LLM 基础设施进行高性能的定制化开发。

该框架适用于需要处理大量 B2C 客户服务或敏感 B2B 业务场景的企业,特别适合那些对交互质量、响应准确性和合规性有极高要求的开发团队。