openaxies 0.5.2 → 0.5.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openaxies",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
package/src/App.js CHANGED
@@ -180,23 +180,21 @@ function AppRoot() {
180
180
  }
181
181
  if (event.type === 'thinking' || event.type === 'token') {
182
182
  const content = typeof event.content === 'string' ? event.content : '';
183
- for (let i = 0; i < content.length; i++) {
184
- accumulated = accumulated + content[i];
185
- const inside = checkThink(accumulated);
186
- setStreamText(accumulated);
187
- setIsThinking(inside);
188
- if (inside === true && thinkStarted === false) {
189
- thinkStarted = true;
190
- thinkStartRef.current = Date.now();
191
- setThinkingElapsed(0);
192
- }
193
- if (inside === false && thinkStarted === true) {
194
- thinkStarted = false;
195
- thinkStartRef.current = null;
196
- setThinkingElapsed(0);
197
- }
198
- await new Promise(function (r) { setTimeout(r, 0); });
183
+ accumulated = accumulated + content;
184
+ const inside = checkThink(accumulated);
185
+ setStreamText(accumulated);
186
+ setIsThinking(inside);
187
+ if (inside === true && thinkStarted === false) {
188
+ thinkStarted = true;
189
+ thinkStartRef.current = Date.now();
190
+ setThinkingElapsed(0);
191
+ }
192
+ if (inside === false && thinkStarted === true) {
193
+ thinkStarted = false;
194
+ thinkStartRef.current = null;
195
+ setThinkingElapsed(0);
199
196
  }
197
+ await new Promise(function (r) { setTimeout(r, 0); });
200
198
  }
201
199
  if (event.type === 'done') break;
202
200
  if (event.type === 'timeout') {
@@ -210,10 +208,9 @@ function AppRoot() {
210
208
  thinkStartRef.current = null;
211
209
  setThinkingElapsed(0);
212
210
  setStreamingActive(false);
213
- const finalText = streamText;
214
211
  setStreamText('');
215
- if (finalText.length > 0) {
216
- setMessages(function (p) { return p.concat([{ role: 'assistant', content: finalText, id: 'a-' + Date.now() }]); });
212
+ if (accumulated.length > 0) {
213
+ setMessages(function (p) { return p.concat([{ role: 'assistant', content: accumulated, id: 'a-' + Date.now() }]); });
217
214
  }
218
215
  } catch (err) {
219
216
  if (connRef.current !== null) clearInterval(connRef.current), connRef.current = null;
@@ -279,7 +276,7 @@ function AppRoot() {
279
276
  h(Text, { key: 'l' + r, color: LOGO_COLORS[r % LOGO_COLORS.length], bold: true }, LOGO[r])
280
277
  );
281
278
  }
282
- const logo = h(Box, { flexDirection: 'column', width: '100%', flexShrink: 0, paddingLeft: 1 }, ...logoEls);
279
+ const logo = h(Box, { flexDirection: 'column', width: '100%', flexShrink: 0, paddingLeft: 0 }, ...logoEls);
283
280
 
284
281
  const viewLines = [];
285
282
  for (let i = 0; i < messages.length; i++) {
@@ -310,7 +307,10 @@ function AppRoot() {
310
307
  }
311
308
 
312
309
  if (viewLines.length === 0) {
313
- viewLines.push({ t: 'idle', text: ' \u25B8 type a message to begin... [/help for commands]' });
310
+ viewLines.push({ t: 'idle', text: ' \u25B8 type a message to begin | /model to switch models | /help for commands' });
311
+ viewLines.push({ t: 'idle', text: '' });
312
+ viewLines.push({ t: 'idle-sm', text: ' Models: OpenAxies Llama | OpenAxies GPT | OpenAxies DeepSeek' });
313
+ viewLines.push({ t: 'idle-sm', text: ' Current: ' + activeLabel });
314
314
  }
315
315
 
316
316
  const visible = Math.max(1, availLines - 1);
@@ -352,7 +352,13 @@ function AppRoot() {
352
352
  } else if (l.t === 'idle') {
353
353
  viewEls.push(
354
354
  h(Box, { key: 'i-' + i, height: 1, paddingLeft: 1 },
355
- h(Text, { color: '#444466' }, l.text)
355
+ h(Text, { color: '#555577' }, l.text)
356
+ )
357
+ );
358
+ } else if (l.t === 'idle-sm') {
359
+ viewEls.push(
360
+ h(Box, { key: 'is-' + i, height: 1, paddingLeft: 1 },
361
+ h(Text, { color: '#333355' }, l.text)
356
362
  )
357
363
  );
358
364
  }
@@ -82,6 +82,7 @@ export async function* callModel(modelConfig, messages, signal) {
82
82
  messages: modelMessages,
83
83
  max_tokens: 4096,
84
84
  temperature: 0.7,
85
+ stream: true,
85
86
  };
86
87
 
87
88
  let lastError = null;
@@ -78,7 +78,7 @@ export async function* streamResponse(endpoint, body, signal) {
78
78
  }, READ_TIMEOUT);
79
79
  }
80
80
 
81
- resetReadTimeout();
81
+ let firstChunk = true;
82
82
 
83
83
  try {
84
84
  while (true) {
@@ -86,12 +86,48 @@ export async function* streamResponse(endpoint, body, signal) {
86
86
  resetReadTimeout();
87
87
 
88
88
  if (result.done === true) {
89
+ if (buffer.trim().length > 0 && firstChunk === false) {
90
+ try {
91
+ const parsed = JSON.parse(buffer);
92
+ const choice = parsed.choices && parsed.choices[0];
93
+ if (choice !== null && choice !== undefined) {
94
+ const msg = choice.message || choice.delta;
95
+ if (msg !== null && msg !== undefined) {
96
+ if (typeof msg.content === 'string' && msg.content.length > 0) {
97
+ yield { type: 'token', content: msg.content };
98
+ }
99
+ }
100
+ }
101
+ } catch (_) {
102
+ }
103
+ }
89
104
  yield { type: 'done' };
90
105
  return;
91
106
  }
92
107
 
93
108
  const chunk = decoder.decode(result.value, { stream: true });
94
109
  buffer = buffer + chunk;
110
+
111
+ if (firstChunk === true && buffer.includes('data: ') === false && buffer.trim().startsWith('{') === true) {
112
+ try {
113
+ const parsed = JSON.parse(buffer);
114
+ const choice = parsed.choices && parsed.choices[0];
115
+ if (choice !== null && choice !== undefined) {
116
+ const msg = choice.message || choice.delta;
117
+ if (msg !== null && msg !== undefined) {
118
+ if (typeof msg.content === 'string' && msg.content.length > 0) {
119
+ yield { type: 'token', content: msg.content };
120
+ }
121
+ }
122
+ }
123
+ yield { type: 'done' };
124
+ return;
125
+ } catch (_) {
126
+ }
127
+ }
128
+
129
+ firstChunk = false;
130
+
95
131
  const lines = buffer.split('\n');
96
132
  buffer = lines.pop() || '';
97
133