Skip to content

Commit 1a091a3

Browse files
committed
chat: add ability to set thread name and use for cell toolbar
- should do this all over but it's a ton of work, so leave for later
1 parent 30117ad commit 1a091a3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/packages/frontend/chat/chatroom.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,7 @@ export function ChatPanel({
452452
}
453453
>
454454
<Icon name={isAI ? "robot" : "users"} style={{ color: "#888" }} />
455-
<StaticMarkdown
456-
value={displayLabel}
457-
style={THREAD_ITEM_LABEL_STYLE}
458-
/>
455+
<div style={THREAD_ITEM_LABEL_STYLE}>{displayLabel}</div>
459456
{unreadCount > 0 && (
460457
<Badge
461458
count={unreadCount}

src/packages/frontend/jupyter/llm/cell-tool.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
import { CSSProperties, useEffect, useMemo, useRef, useState } from "react";
2222
import { defineMessage, FormattedMessage, useIntl } from "react-intl";
2323
import { Entries } from "type-fest";
24-
24+
import { trunc } from "@cocalc/util/misc";
2525
import { LanguageSelector } from "@cocalc/frontend/account/i18n-selector";
2626
import { useAsyncEffect } from "@cocalc/frontend/app-framework";
2727
import getChatActions from "@cocalc/frontend/chat/get-actions";
@@ -601,7 +601,7 @@ export function LLMCellTool({ actions, id, style, llmTools, cellType }: Props) {
601601

602602
async function getExplanation(preview: boolean) {
603603
if (actions == null) return; // shouldn't happen
604-
const { message } = await createMessage(preview);
604+
const { message, name } = await createMessage(preview);
605605
if (!message) {
606606
console.warn("getExplanation -- no cell with id", id);
607607
return;
@@ -613,6 +613,7 @@ export function LLMCellTool({ actions, id, style, llmTools, cellType }: Props) {
613613
input: message,
614614
tag: `jupyter-cell-llm:${mode}`,
615615
noNotification: true,
616+
name,
616617
});
617618

618619
// we also log this
@@ -628,7 +629,7 @@ export function LLMCellTool({ actions, id, style, llmTools, cellType }: Props) {
628629

629630
async function createMessage(
630631
preview: boolean,
631-
): Promise<{ message: string; tokens: number }> {
632+
): Promise<{ message: string; tokens: number; name?: string }> {
632633
const empty = { message: "", tokens: 0 };
633634
if (actions == null || mode == null || llmTools == null) return empty;
634635
const { model } = llmTools;
@@ -637,14 +638,15 @@ export function LLMCellTool({ actions, id, style, llmTools, cellType }: Props) {
637638
const cell = actions.store.get("cells").get(id);
638639
if (!cell) return empty;
639640

640-
const { message, tokens } = await createMessageText({
641+
const { message, tokens, name } = await createMessageText({
641642
cell,
642643
model,
643644
preview,
644645
});
645646
return {
646647
message: preview ? message : `${modelToMention(model)} ${message}`,
647648
tokens,
649+
name,
648650
};
649651
}
650652

@@ -656,7 +658,7 @@ export function LLMCellTool({ actions, id, style, llmTools, cellType }: Props) {
656658
model: LanguageModel;
657659
preview: boolean;
658660
cell: any;
659-
}): Promise<{ message: string; tokens: number }> {
661+
}): Promise<{ message: string; tokens: number; name?: string }> {
660662
if (mode == null || actions == null)
661663
return { message: "Error: no mode selected.", tokens: 0 };
662664

@@ -739,6 +741,7 @@ export function LLMCellTool({ actions, id, style, llmTools, cellType }: Props) {
739741
return {
740742
message,
741743
tokens: numTokensUpperBound(message, getMaxTokens(model)),
744+
name: trunc(input),
742745
};
743746
}
744747

0 commit comments

Comments
 (0)