Options
All
  • Public
  • Public/Protected
  • All
Menu

Module nim/AiInterface

Index

Type aliases

NIMAIModelCallContent: { msg: string; type: number }

Type declaration

  • msg: string

    请求/响应的文本内容

  • type: number

    类型, 暂时只有 0, 代表文本

NIMAIModelCallMessage: { msg: string; role: string; type: number }

Type declaration

  • msg: string

    请求/响应的文本内容

  • role: string

    上下文内容的角色.

    注: 请开发者自行判定自己发的消息选 user, 若是机器人发的消息是选 assistant

    'system' 系统
    'user' 用户
    'assistant' 助手

  • type: number

    类型, 暂时只有 0, 代表文本

NIMAIModelCallResult: { accountId: string; aiRAGs?: NIMAIRAGInfo[]; aiStream: boolean; aiStreamStatus: NIMAIModelStreamCallStatus; code: number; content: NIMAIModelCallContent; requestId: string; timestamp: number }

AI 透传接口的响应的回调的结构体

Type declaration

  • accountId: string

    机器人账号 ID

  • Optional aiRAGs?: NIMAIRAGInfo[]

    数字人回复内容的引用资源列表

  • aiStream: boolean

    是否是流式响应,默认 false

  • aiStreamStatus: NIMAIModelStreamCallStatus

    数字人流式响应状态

  • code: number

    本次响应的状态, 200 为成功, 其他的都是失败

  • content: NIMAIModelCallContent

    响应的内容

  • requestId: string

    请求 ID

  • timestamp: number

    回复的时间戳

NIMAIModelConfig: { maxTokens?: number; model: string; prompt: string; promptKeys?: string[]; temperature?: string; topP?: string }

Type declaration

  • Optional maxTokens?: number

    模型最大tokens数量

  • model: string

    具体大模型版本模型名称

  • prompt: string

    提示词

  • Optional promptKeys?: string[]

    提示词相关的变量

  • Optional temperature?: string

    随机性和多样性的程度值

  • Optional topP?: string

    核采样方法的概率阈值

NIMAIModelConfigParams: { maxTokens?: number; prompt?: string; temperature?: string; topP?: string }

AI 大模型配置

Type declaration

  • Optional maxTokens?: number

    模型最大tokens数量

  • Optional prompt?: string

    提示词

  • Optional temperature?: string

    随机性和多样性的程度值

  • Optional topP?: string

    核采样方法的概率阈值

NIMAIModelStreamCallChunk: { chunkTime: number; content: string; index: number; type: number }

Type declaration

  • chunkTime: number

    数字人流式回复当前分片时间

  • content: string

    数字人流式回复分片文本

  • index: number

    分片序号,从0开始

  • type: number

    类型,当前仅支持0表示文本

NIMAIModelStreamCallContent: { lastChunk: NIMAIModelStreamCallChunk; msg: string; type: number }

Type declaration

  • lastChunk: NIMAIModelStreamCallChunk

    数字人流式回复最近一个分片

  • msg: string

    请求/响应的文本内容

  • type: number

    类型, 暂时只有 0, 代表文本

NIMAIModelStreamCallResult: { accountId: string; aiRAGs?: NIMAIRAGInfo[]; code: number; content?: NIMAIModelStreamCallContent; requestId: string; timestamp: number }

透传接口的 AI 流式回复的结构体.

Type declaration

  • accountId: string

    机器人账号 ID

  • Optional aiRAGs?: NIMAIRAGInfo[]

    数字人回复内容的引用资源列表

  • code: number

    本次响应的状态, 200 为成功, 其他的都是失败

  • Optional content?: NIMAIModelStreamCallContent

    响应的内容

  • requestId: string

    请求 ID

  • timestamp: number

    分片时间戳

NIMAIModelStreamCallStopParams: { accountId: string; requestId: string; done?: any }

Type declaration

NIMAIRAGInfo: { description?: string; icon?: string; name?: string; time?: number; title?: string; url?: string }

Type declaration

  • Optional description?: string

    引用资源的描述

  • Optional icon?: string

    rag 图标

  • Optional name?: string

    rag 名称

  • Optional time?: number

    引用资源的时间

  • Optional title?: string

    引用资源的title

  • Optional url?: string

    引用资源的url

NIMProxyAICallAntispamConfig: { antispamBusinessId?: string; antispamEnabled?: boolean }

Type declaration

  • Optional antispamBusinessId?: string

    指定易盾业务id

  • Optional antispamEnabled?: boolean

    指定消息是否需要经过安全通。默认为 true

    对于已开通安全通的用户有效,默认消息都会走安全通,如果对单条消息设置 enable 为 false,则此消息不会走安全通

NIMProxyAIModelCallParams: { accountId: string; aiStream?: boolean; antispamConfig?: NIMProxyAICallAntispamConfig; content: NIMAIModelCallContent; messages?: NIMAIModelCallMessage[]; modelConfigParams?: NIMAIModelConfigParams; promptVariables?: string; requestId: string; done?: any }

Type declaration

  • accountId: string

    机器人账号ID

  • Optional aiStream?: boolean

    是否流式返回. 默认 false

  • Optional antispamConfig?: NIMProxyAICallAntispamConfig

    反垃圾配置

  • content: NIMAIModelCallContent

    请求大模型的内容

  • Optional messages?: NIMAIModelCallMessage[]

    请求调用上下文内容

  • Optional modelConfigParams?: NIMAIModelConfigParams

    请求接口模型相关参数配置, 如果参数不为空,则默认覆盖控制相关配置

  • Optional promptVariables?: string

    提示词变量占位符替换. JSON 序列化的字符串, 用于填充 prompt 中的变量

    注: 如果 NIMAIUser 中的 modelConfig.promptKeys 存在且数组长度不为 0 ,则必填.

  • requestId: string

    请求id

    注: 需要用请求 id 将整个串联应答流程, 建议采用 uuid 算法避免重复

  • done?:function