1.1.15 • Published 4 months ago

@agent-client/dashscope v1.1.15

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Agent UI

一个基于 react 和 TypeScript 并兼容于各种前端框架的 Agent UI 组件库,提供聊天界 面、浮动按钮等组件。

安装

npm install @agent-client/dashscope

使用方法

导入组件

import { AgentClient } from "@agent-client/dashscope"

FloatButton 组件

<script setup>
import { AgentClient } from "@agent-client/dashscope"
const agent = AgentClient.createAgentClient({
  token: "your-token",
  agentCode: "your-agent-code",
  tagName: "float-button",
})
</script>

<template>
  <float-button :agent-id="agent.id" />
</template>

Agent 配置

import { AgentClient } from "@agent-client/dashscope"

// 创建 AgentClient 实例
const agent = AgentClient.createAgentClient({
  token: "your-token",
  agentCode: "your-agent-code",
  tagName: "float-button",
})

运行 Agent

// 运行agent,输入提示词,输出消息
const { response, abort } = await agent.run({
  prompt: "你好",
})
const message = await response

// 从消息中解构出文本内容、角色、消息id等信息
const { content, role, id } = message

开发

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建库
npm run build:lib

# 发布到 npm
npm publish

许可证

MIT