mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 00:02:45 +00:00
Add defaultConvertToLlm to web-ui, simplify example
- web-ui exports: defaultConvertToLlm, convertAttachments, isUserMessageWithAttachments, isArtifactMessage - defaultConvertToLlm handles UserMessageWithAttachments and filters ArtifactMessage - Example's customMessageTransformer now extends defaultConvertToLlm - Removes duplicated attachment conversion logic from example
This commit is contained in:
parent
7a39f9eb11
commit
13a1991ec2
6 changed files with 127 additions and 76 deletions
|
|
@ -74,8 +74,8 @@ let chatPanel: ChatPanel;
|
|||
let agentUnsubscribe: (() => void) | undefined;
|
||||
|
||||
const generateTitle = (messages: AgentMessage[]): string => {
|
||||
const firstUserMsg = messages.find((m) => m.role === "user");
|
||||
if (!firstUserMsg || firstUserMsg.role !== "user") return "";
|
||||
const firstUserMsg = messages.find((m) => m.role === "user" || m.role === "user-with-attachments");
|
||||
if (!firstUserMsg || (firstUserMsg.role !== "user" && firstUserMsg.role !== "user-with-attachments")) return "";
|
||||
|
||||
let text = "";
|
||||
const content = firstUserMsg.content;
|
||||
|
|
@ -98,7 +98,7 @@ const generateTitle = (messages: AgentMessage[]): string => {
|
|||
};
|
||||
|
||||
const shouldSaveSession = (messages: AgentMessage[]): boolean => {
|
||||
const hasUserMsg = messages.some((m: any) => m.role === "user");
|
||||
const hasUserMsg = messages.some((m: any) => m.role === "user" || m.role === "user-with-attachments");
|
||||
const hasAssistantMsg = messages.some((m: any) => m.role === "assistant");
|
||||
return hasUserMsg && hasAssistantMsg;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue