thebird 1.2.12 → 1.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/docs/app.js +9 -3
  2. package/package.json +1 -1
package/docs/app.js CHANGED
@@ -160,13 +160,19 @@ class BirdChat extends HTMLElement {
160
160
  this.setState({ messages, streaming: true, status: '', streamingText: '' });
161
161
  try {
162
162
  let full = '';
163
- for await (const chunk of streamGenerate(apiKey, model, convertMessages(messages))) {
163
+ let rafPending = false;
164
+ const gen = streamGenerate(apiKey, model, convertMessages(messages));
165
+ for await (const chunk of gen) {
164
166
  full += chunk;
165
- this.setState({ streamingText: full });
167
+ if (!rafPending) {
168
+ rafPending = true;
169
+ const snap = full;
170
+ requestAnimationFrame(() => { this.setState({ streamingText: snap }); rafPending = false; });
171
+ }
166
172
  }
173
+ this.setState({ messages: [...messages, { role: 'assistant', content: full || '(empty)' }], streaming: false, streamingText: '' });
167
174
  const list = document.getElementById('msg-list');
168
175
  if (list) list.scrollTop = list.scrollHeight;
169
- this.setState({ messages: [...messages, { role: 'assistant', content: full || '(empty)' }], streaming: false, streamingText: '' });
170
176
  } catch (err) {
171
177
  this.setState({ streaming: false, streamingText: '', status: 'Error: ' + (err?.message || String(err)) });
172
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thebird",
3
- "version": "1.2.12",
3
+ "version": "1.2.13",
4
4
  "description": "Anthropic SDK to Gemini streaming bridge — drop-in proxy that translates Anthropic message format and tool calls to Google Gemini",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",