Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

I got tired of rewriting the same AI boilerplate so I built a library to fix it

说明与用途

Strand通过提供对话、流式处理和工具调用的钩子,消除了在React中集成AI所需的200+行模板代码。

问题

Developers repeatedly rewrite over 200 lines of boilerplate for AI integration in React apps, handling streaming, history, tool calls, error handling, and loading states manually.

结果

Strand reduces boilerplate from 200+ lines to a concise hook-based API, handling streaming, history, tool calls, cancellation, and detailed loading states across providers.

工作流

  • 1. Install Strand packages: npm install @strand-js/core @strand-js/react zod
  • 2. Install provider package (e.g., @strand-js/anthropic)
  • 3. Import useConversation in component: const {messages, send, isPending, isStreaming, cancel} = useConversation({system:'You are a helpful assistant.'});
  • 4. Use send(text) to initiate conversation; handle UI based on isPending/isStreaming states.
  • 5. For tool calls, use useToolCall('tool_name') to access status, input, output across any component.
  • 6. Swap AI provider by changing server import; no frontend changes needed.

证据

After the third project I stopped and asked: why is nobody solving this the way RTK Query solved REST APIs?

来源

Works with Anthropic, OpenAI, and Google Gemini

来源

  • 记录日期: 2026-09-09T06:16:43.915Z