Improve chat title generation or smth
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
import * as defaultApi from "./api.js";
|
||||
import {updateReasoning, finishReasoning} from "./reasoning.js";
|
||||
import {createStreamRenderer} from "./streamRenderer.js";
|
||||
import {titleFromFirstMessage} from "./chatTitle.js";
|
||||
|
||||
export function createComposerController({
|
||||
state, elements, attachmentComposer, webSearchButton, reasoningToggle, webSearchToggle,
|
||||
@@ -101,12 +100,9 @@ export function createComposerController({
|
||||
}
|
||||
const currentChat = getChatById(chatId);
|
||||
if (currentChat && !currentChat.assistant_persona_id && currentChat.title === "New chat") {
|
||||
const title = titleFromFirstMessage(message);
|
||||
const renamed = await api.put(`/chats/${chatId}`, {title}, {signal});
|
||||
const renamed = await api.put(`/chats/${chatId}`, {title: currentChat.title}, {signal});
|
||||
signal.throwIfAborted();
|
||||
if (renamed.error) throw new Error(renamed.error);
|
||||
currentChat.title = title;
|
||||
updateWorkspaceCopy(); renderChatList();
|
||||
}
|
||||
signal.throwIfAborted();
|
||||
if (visible()) {
|
||||
@@ -149,11 +145,24 @@ export function createComposerController({
|
||||
: searchState === "no_relevant_results" ? "No sufficiently relevant results. Generating response..."
|
||||
: sourceCount === 0 ? "No web results found. Generating response..." : "Generating response...";
|
||||
},
|
||||
onDone: ({reply, sources}) => { completedReply = reply; completedSources = sources; }
|
||||
onDone: ({reply, sources, chatTitle}) => {
|
||||
completedReply = reply; completedSources = sources;
|
||||
if (chatTitle && currentChat) {
|
||||
currentChat.title = chatTitle;
|
||||
updateWorkspaceCopy(); renderChatList();
|
||||
}
|
||||
}
|
||||
}, {signal});
|
||||
rendering.flush();
|
||||
rendering.dispose();
|
||||
const updatedChat = getChatById(chatId);
|
||||
if (api === defaultApi && currentChat && !currentChat.assistant_persona_id && currentChat.title === "New chat") {
|
||||
const titled = await api.post(`/chats/${chatId}/title`, {message, model}, {signal});
|
||||
if (!signal.aborted && titled.title) {
|
||||
currentChat.title = titled.title;
|
||||
updateWorkspaceCopy(); renderChatList();
|
||||
}
|
||||
}
|
||||
if (updatedChat && completedReply !== null) {
|
||||
updatedChat.last_message_preview = completedReply.slice(0, 180);
|
||||
updatedChat.updated_at = new Date().toISOString();
|
||||
|
||||
Reference in New Issue
Block a user