thebird 1.2.12 → 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 -8
  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,13 +156,25 @@ class BirdChat extends HTMLElement {
160
156
  this.setState({ messages, streaming: true, status: '', streamingText: '' });
161
157
  try {
162
158
  let full = '';
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);
163
170
  for await (const chunk of streamGenerate(apiKey, model, convertMessages(messages))) {
164
171
  full += chunk;
165
- this.setState({ streamingText: full });
172
+ streamEl.textContent = full;
173
+ if (list) list.scrollTop = list.scrollHeight;
166
174
  }
167
- const list = document.getElementById('msg-list');
168
- if (list) list.scrollTop = list.scrollHeight;
175
+ wrap.remove();
169
176
  this.setState({ messages: [...messages, { role: 'assistant', content: full || '(empty)' }], streaming: false, streamingText: '' });
177
+ if (list) list.scrollTop = list.scrollHeight;
170
178
  } catch (err) {
171
179
  this.setState({ streaming: false, streamingText: '', status: 'Error: ' + (err?.message || String(err)) });
172
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thebird",
3
- "version": "1.2.12",
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",