跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.kontext.so/llms.txt

Use this file to discover all available pages before exploring further.

插件 / AdsProvider 选项

publisherToken
string
必填
你的 publisher token。
userId
string
必填
在用户整个生命周期内保持不变的唯一标识(用于再营销与奖励广告)。
userEmail
string
用户邮箱。
conversationId
string
必填
对话的唯一 ID。
enabledPlacementCodes
array
本次对话启用的 placement code。默认为 ['inlineAd']
character
object
本次对话使用的 character 对象。
regulatory
object
本次对话的合规对象。
variantId
string
发布方提供的用户分群标识(用于 A/B 测试)。
onEvent
function
事件发生时的回调。详见下方”支持的事件”章节。
onDebugEvent
function
SDK 内部诊断事件的回调。接收 (name, data?)——在接入期间排查 preload / session 行为时很有用。默认关闭。

useAds() composable

返回 addMessage,一个总是路由到当前会话的转发函数。如果 <AdsProvider> 切换了会话(例如 publisherToken 改变),下一次调用会自动指向新的会话。
addMessage
function
必填
(message: Message, options?: AddMessageOptions) => void —— 向 SDK 注册一条新消息。下一次预加载会被自动安排。AddMessageOptions 目前提供一个开关:

Message 结构

id
string
必填
消息的唯一 ID。
role
string
必填
消息角色(userassistant)。
content
string
必填
消息文本。
createdAt
Date
必填
消息创建时间戳。

InlineAd 属性

messageId
string
必填
本广告所属消息的唯一 ID。
code
string
Onboarding 时提供的 placement code。默认为 'inlineAd'
theme
string
广告主题,例如 lightdark

Slots

wrapper
slot
render-prop 形式的具名插槽,允许你用自己的 DOM 结构包裹广告 iframe。插槽接收已渲染的广告作为 ad
<InlineAd :messageId="m.id">
  <template #wrapper="{ ad }">
    <div class="my-ad-card">{{ ad }}</div>
  </template>
</InlineAd>

支持的事件

ad.clicked

用户点击了广告。

ad.viewed

用户已查看广告。

ad.filled

有可投放的广告。

ad.no-fill

没有可投放的广告。

ad.render-started

在第一个 token 到达之前触发。

ad.render-completed

在最后一个 token 到达之后触发。

ad.error

出现错误时触发。

video.started

视频开始播放时触发。

video.completed

视频播放完成时触发。

reward.granted

激励广告向用户发放奖励时触发。