const { aparteGlobalConfig } = window.aparte;
// Every get_weather call is drawn by this instead of the default row. Returning an
// element (not a string) means the model's data never goes through innerHTML.
aparteGlobalConfig.registerToolRenderer('get_weather', {
render(segment) {
const card = document.createElement('div');
card.className = 'aparte-card';
const body = document.createElement('div');
body.className = 'aparte-card__body';
body.textContent = segment.status === 'resolved'
? `${segment.toolCall.input.city}: ${segment.result}`
: `Checking the weather in ${segment.toolCall.input.city}…`;
card.append(body);
return card;
},
});
document.querySelector('aparte-chat-bubble').setSegments([
{ id: 's1', type: 'tool_call', status: 'resolved', toolCall: { id: 't1', name: 'get_weather', input: { city: 'Lille' } }, result: 'cloudy, 14 °C' },
]);