thebird 1.2.13 → 1.2.14

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 +16 -14
  2. package/package.json +1 -1
package/docs/app.js CHANGED
@@ -127,11 +127,7 @@ class BirdChat extends HTMLElement {
127
127
  <div key=${i} class=${'flex ' + (m.role === 'user' ? 'justify-end' : 'justify-start')}>
128
128
  <div class=${'msg-bubble card px-4 py-3 text-sm leading-relaxed ' + (m.role === 'user' ? 'bg-primary text-primary-content' : 'bg-base-200 text-base-content')}>${m.content}</div>
129
129
  </div>`)}
130
- ${streamingText && html`
131
- <div class="flex justify-start">
132
- <div class="msg-bubble card bg-base-200 text-base-content px-4 py-3 text-sm leading-relaxed">${streamingText}<span class="animate-pulse ml-1">▋</span></div>
133
- </div>`}
134
- ${!streamingText && streaming && html`<div class="flex justify-start"><div class="card bg-base-200 px-4 py-3"><span class="loading loading-dots loading-sm"></span></div></div>`}
130
+ ${streaming && !streamingText && html`<div class="flex justify-start"><div class="card bg-base-200 px-4 py-3"><span class="loading loading-dots loading-sm"></span></div></div>`}
135
131
  </div>
136
132
 
137
133
  ${status && html`<div class="text-xs text-error px-4 pb-1">${status}</div>`}
@@ -160,18 +156,24 @@ class BirdChat extends HTMLElement {
160
156
  this.setState({ messages, streaming: true, status: '', streamingText: '' });
161
157
  try {
162
158
  let full = '';
163
- let rafPending = false;
164
- const gen = streamGenerate(apiKey, model, convertMessages(messages));
165
- for await (const chunk of gen) {
159
+ const streamEl = document.createElement('div');
160
+ streamEl.className = 'msg-bubble card bg-base-200 text-base-content px-4 py-3 text-sm leading-relaxed';
161
+ const cursor = document.createElement('span');
162
+ cursor.className = 'animate-pulse ml-1';
163
+ cursor.textContent = '▋';
164
+ const list = this.querySelector('#msg-list');
165
+ const wrap = document.createElement('div');
166
+ wrap.className = 'flex justify-start';
167
+ wrap.appendChild(streamEl);
168
+ wrap.appendChild(cursor);
169
+ if (list) list.appendChild(wrap);
170
+ for await (const chunk of streamGenerate(apiKey, model, convertMessages(messages))) {
166
171
  full += chunk;
167
- if (!rafPending) {
168
- rafPending = true;
169
- const snap = full;
170
- requestAnimationFrame(() => { this.setState({ streamingText: snap }); rafPending = false; });
171
- }
172
+ streamEl.textContent = full;
173
+ if (list) list.scrollTop = list.scrollHeight;
172
174
  }
175
+ wrap.remove();
173
176
  this.setState({ messages: [...messages, { role: 'assistant', content: full || '(empty)' }], streaming: false, streamingText: '' });
174
- const list = document.getElementById('msg-list');
175
177
  if (list) list.scrollTop = list.scrollHeight;
176
178
  } catch (err) {
177
179
  this.setState({ streaming: false, streamingText: '', status: 'Error: ' + (err?.message || String(err)) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thebird",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
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",