@lingshuai/chat-taro
v0.1.4
Published
Taro 多端 AI 对话 SDK - 支持微信小程序/支付宝小程序/抖音小程序/H5/App
Maintainers
Readme
@lingshuai/chat-taro
Taro multi-end AI chat SDK for WeChat Mini Program, Alipay Mini Program, Douyin Mini Program, H5, and App.
Install
pnpm add @lingshuai/chat-taroor
npm install @lingshuai/chat-taroQuick Start
import { useChat } from '@lingshuai/chat-taro';
export default function ChatPage() {
const { messages, sendMessage, loading, error } = useChat({
apiKey: 'sk_live_xxx',
appId: 'your-project-id',
baseUrl: 'https://zhiyuanshu.cn/api',
});
return null;
}Features
- Text chat with streaming response
- Multimodal attachments for image, audio, video, and file
- Structured output with JSON Schema
- AG-UI actions and HITL confirmation
- Conversation persistence and recovery
Structured Output With Attachments
When sendStructuredMessage(content, outputSchema, attachments) is used with multimodal attachments, the SDK keeps attachments intact and injects the schema constraint into the prompt instead of sending a standalone outputSchema field. This avoids image URL forwarding issues on multimodal structured-output requests while keeping the return type compatible with StructuredOutputResponse<T>.
Error Handling
The SDK treats these cases as failures and will not create a fake successful assistant message or persist a failed conversation id:
- HTTP status is not 2xx
- response
code >= 400 contentorrawJsoncontainsException: <status>
Docs
- Repo docs:
docs/taro - Public docs route:
/docs/taro
