jdelavande HF Staff commited on
Commit
1b054fa
·
1 Parent(s): b282a7d

add text info

Browse files
src/lib/components/chat/ChatIntroduction.svelte CHANGED
@@ -40,7 +40,7 @@
40
  </p>
41
  </div>
42
  </div>
43
- <div class="lg:col-span-2 lg:pl-24">
44
  {#each announcementBanners as banner}
45
  <AnnouncementBanner classNames="mb-4" title={banner.title}>
46
  <a
@@ -79,8 +79,12 @@
79
  <ModelCardMetadata variant="dark" model={currentModel} />
80
  </div>
81
  </div>
82
- {#if currentModel.promptExamples}
83
- <div class="lg:col-span-3 lg:mt-6">
 
 
 
 
84
  <p class="mb-3 text-gray-600 dark:text-gray-300">Examples</p>
85
  <div class="grid gap-3 lg:grid-cols-3 lg:gap-5">
86
  {#each currentModel.promptExamples as example}
@@ -93,6 +97,7 @@
93
  </button>
94
  {/each}
95
  </div>
96
- </div>{/if}
 
97
  <div class="h-40 sm:h-24"></div>
98
  </div>
 
40
  </p>
41
  </div>
42
  </div>
43
+ <div class="lg:col-span-2">
44
  {#each announcementBanners as banner}
45
  <AnnouncementBanner classNames="mb-4" title={banner.title}>
46
  <a
 
79
  <ModelCardMetadata variant="dark" model={currentModel} />
80
  </div>
81
  </div>
82
+ <div class="lg:col-span-3">
83
+ <div class="mb-8 rounded-xl border border-gray-100 bg-gray-50 p-6 dark:border-gray-800 dark:bg-gray-800">
84
+ <h2 class="mb-4 text-xl font-semibold">Tracking Energy Use in ChatUI 🤗 </h2>
85
+ <p class="mb-4"> How much energy do your chatbot conversations consume? The first AI chat interface with real-time energy estimates! </p> <p class="mb-4"> This tool helps users compare models, tasks, and strategies (like reasoning), empowering informed decisions. Even small energy savings can scale up across millions of queries — model choice or output length can lead to major environmental impact. </p> <p class="mb-4"> To make these costs more relatable, we compare them to everyday activities (like phone charging or driving) using EPA-based equivalents. </p> <p> With projects like the AI Energy Score and broader research on AI’s energy footprint, we're pushing for transparency in the open-source community. One day, energy usage could be as visible as nutrition labels on food! </p>
86
+ </div>
87
+ {#if currentModel.promptExamples}
88
  <p class="mb-3 text-gray-600 dark:text-gray-300">Examples</p>
89
  <div class="grid gap-3 lg:grid-cols-3 lg:gap-5">
90
  {#each currentModel.promptExamples as example}
 
97
  </button>
98
  {/each}
99
  </div>
100
+ {/if}
101
+ </div>
102
  <div class="h-40 sm:h-24"></div>
103
  </div>
src/routes/conversation/[id]/+server.ts CHANGED
@@ -326,7 +326,17 @@ export async function POST({ request, locals, params, getClientAddress }) {
326
  // update the conversation with the new messages
327
  await collections.conversations.updateOne(
328
  { _id: convId },
329
- { $set: { messages: conv.messages, title: conv.title, updatedAt: new Date() } }
 
 
 
 
 
 
 
 
 
 
330
  );
331
 
332
  let doneStreaming = false;
@@ -423,8 +433,6 @@ export async function POST({ request, locals, params, getClientAddress }) {
423
  messageToWriteTo?.updates?.push(event);
424
  }
425
 
426
-
427
-
428
  // Avoid remote keylogging attack executed by watching packet lengths
429
  // by padding the text with null chars to a fixed length
430
  // https://cdn.arstechnica.net/wp-content/uploads/2024/03/LLM-Side-Channel.pdf
 
326
  // update the conversation with the new messages
327
  await collections.conversations.updateOne(
328
  { _id: convId },
329
+ {
330
+ $set: {
331
+ messages: conv.messages,
332
+ title: conv.title,
333
+ updatedAt: new Date(),
334
+ energy_consumption: conv.messages.reduce((total, message) => {
335
+ const energy = message.metadata?.energy_wh;
336
+ return total + (typeof energy === "number" ? energy : 0);
337
+ }, 0),
338
+ },
339
+ }
340
  );
341
 
342
  let doneStreaming = false;
 
433
  messageToWriteTo?.updates?.push(event);
434
  }
435
 
 
 
436
  // Avoid remote keylogging attack executed by watching packet lengths
437
  // by padding the text with null chars to a fixed length
438
  // https://cdn.arstechnica.net/wp-content/uploads/2024/03/LLM-Side-Channel.pdf