# smartai **Repository Path**: smartchart/smartai ## Basic Information - **Project Name**: smartai - **Description**: ai plug for smartchart - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-08-11 - **Last Updated**: 2026-08-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SmartAI **SmartChart 的 AI 插件集合** — 为 [SmartChart](https://www.smartchart.cn/) 平台提供 25+ 外部服务连接器,涵盖 AI 大模型、即时通讯、数据源、物联网及办公自动化等场景。 --- ## 项目概述 SmartAI 是 SmartChart 生态的扩展插件包,每个模块以统一接口(`dataset()` / `insert_dataset()`)对接一种外部服务,可被 SmartChart 数据源框架直接调用,也可独立使用。 - **版本**:8.0 - **作者**:JohnYan - **Python**:>= 3.6(推荐 3.12) - **许可证**:Apache License 2.0 --- ## 模块一览 ### 🤖 AI 大模型 | 模块 | 说明 | |------|------| | `anthropic` | Anthropic Claude API,支持流式输出与 Extended Thinking | | `bailianAI` | 阿里百炼(DashScope)应用接口,支持会话管理与流式响应 | | `dashAI` | DashScope 多服务封装:文本生成、向量嵌入、图像合成、多模态对话 | ### 💬 即时通讯 & 协作平台 | 模块 | 说明 | |------|------| | `dingdingMsg` | 钉钉企业应用工作通知(支持 text / markdown / oa / action_card 等) | | `dingdingWebhook` | 钉钉机器人 Webhook,HMAC-SHA256 签名校验 | | `feishuMsg` | 飞书 / Lark 应用消息推送,自动推断 receive_id_type | | `feishuWebhook` | 飞书机器人 Webhook,支持签名验证与 Markdown → Post 富文本转换 | | `qiweiMsg` | 企业微信应用消息,支持多收件人类型 | | `qiweiWebhook` | 企业微信机器人 Webhook,自动检测 Markdown | | `slackWebhook` | Slack Incoming Webhook & chat.postMessage API | | `telegramBot` | Telegram Bot API,支持 HTML / MarkdownV2 解析 | ### 📊 数据源 & API | 模块 | 说明 | |------|------| | `httpApi` | 通用 RESTful API 调用,动态变量替换,多种认证方式 | | `graphql` | GraphQL 查询 / 变更,灵活变量与嵌套结果提取 | | `maxcompute` | 阿里云 MaxCompute (ODPS) SQL 数据源驱动 | | `kafkaconn` | Kafka 消费者 / 生产者,支持 SASL 认证与 JSON 自动展开 | | `prometheus` | Prometheus 指标查询 | | `vectorPostgres` | PostgreSQL 向量数据库,DashScope 文本嵌入 | | `vectorStarrocks` | StarRocks 向量数据库操作 | ### 📧 通信渠道 | 模块 | 说明 | |------|------| | `sms` | 短信发送(阿里云 / 腾讯云 / 自定义 HTTP 接口) | | `smtpmail` | SMTP 邮件发送,HTML 内容,SSL/TLS | ### 🏢 办公 & 电子表格 | 模块 | 说明 | |------|------| | `dingdingExcel` | 钉钉电子表格数据读取,Token 缓存 | | `feishuExcel` | 飞书电子表格读写操作 | ### 🔧 工具 & IoT | 模块 | 说明 | |------|------| | `mqtt` | MQTT 协议发布 / 订阅,QoS 与 TLS 支持 | | `py` | Python 沙箱执行(RestrictedPython),安全代码求值 | | `webhookGeneric` | 通用 Webhook 推送,HMAC 签名与模板渲染 | --- ## 安装 ```bash # 从源码安装 pip install . # 或开发模式 pip install -e . ``` --- ## 配置说明 所有模块遵循统一的配置字典格式: ```python config = { 'host': '服务地址 / URL / 收件人', 'user': '用户名 / App ID / Access Key', 'password': '密码 / App Secret / Token', 'db': '附加配置(数据库名 / 扩展参数 JSON)', 'remark': '备注 / 额外参数 JSON 字符串', } ``` 各模块的具体配置字段含义请参考对应文件顶部的文档注释。 --- ## 快速示例 ### 调用 AI 模型 ```python from smart_chart.common.lib import dashAI config = {'host': 'https://dashscope.aliyuncs.com', 'user': 'sk-xxx'} sql_list = ['你好,请介绍一下你自己'] result = dashAI.dataset(sql_list, config) ``` ### 发送飞书消息 ```python from smart_chart.common.lib import feishuMsg config = { 'user': 'your_app_id', 'password': 'your_app_secret', 'host': 'ou_xxxxxxxxxxxx', # 收件人 open_id } sql_list = ['## 告警\n服务器 CPU 使用率超过 95%'] feishuMsg.dataset(sql_list, config) ``` ### 查询 Kafka 数据 ```python from smart_chart.common.lib import kafkaconn config = { 'host': 'kafka-broker:9092', 'user': 'topic_name', 'password': '', 'db': 'consumer_group', } sql_list = [''] result = kafkaconn.dataset(sql_list, config) ``` --- ## 项目结构 ``` smartai/ ├── setup.py # 包安装配置 ├── MANIFEST.in # 打包清单 └── smart_chart/ └── common/ └── lib/ ├── __init__.py ├── anthropic.py # Anthropic Claude ├── bailianAI.py # 阿里百炼 ├── dashAI.py # DashScope 多服务 ├── dingdingExcel.py # 钉钉电子表格 ├── dingdingMsg.py # 钉钉工作通知 ├── dingdingWebhook.py # 钉钉机器人 Webhook ├── feishuExcel.py # 飞书电子表格 ├── feishuMsg.py # 飞书应用消息 ├── feishuWebhook.py # 飞书机器人 Webhook ├── graphql.py # GraphQL 客户端 ├── httpApi.py # RESTful API ├── kafkaconn.py # Kafka 连接 ├── maxcompute.py # MaxCompute 数据源 ├── mqtt.py # MQTT 协议 ├── prometheus.py # Prometheus 查询 ├── py.py # Python 沙箱 ├── qiweiMsg.py # 企微应用消息 ├── qiweiWebhook.py # 企微机器人 Webhook ├── slackWebhook.py # Slack Webhook ├── sms.py # 短信发送 ├── smtpmail.py # SMTP 邮件 ├── telegramBot.py # Telegram Bot ├── vectorPostgres.py # PostgreSQL 向量库 ├── vectorStarrocks.py # StarRocks 向量库 └── webhookGeneric.py # 通用 Webhook ``` --- ## 相关链接 - 官网:https://www.smartchart.cn/ - 许可证:[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)