@@ -60,8 +60,6 @@ export const NOT_SUPPORT_JSON_FORMAT_MODELS = [
|
||||
|
||||
export const CHAT_SYSTEM_PROMPT_TEMPLATE = `You are {name}.
|
||||
{agent_prompt}
|
||||
|
||||
You are chatting in an online chat room.
|
||||
{agent_chat_prompt}
|
||||
|
||||
[Rules must be followed]
|
||||
|
||||
@@ -66,6 +66,16 @@ export class ChatMember extends Model<ChatMember> {
|
||||
})
|
||||
agent: ChatAgent;
|
||||
|
||||
@Column(DataType.VIRTUAL)
|
||||
get name(): string {
|
||||
if (this.userType === "User") {
|
||||
return this.user.name;
|
||||
} else if (this.userType === "Agent") {
|
||||
return this.agent.name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Column(DataType.VIRTUAL)
|
||||
get user(): {
|
||||
name: string;
|
||||
|
||||
@@ -385,7 +385,7 @@ const ChatUserMessageActions = (props: {
|
||||
</div>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent>
|
||||
<div className="p-4 font-serif border-t">
|
||||
<div className="p-4 font-serif border-t max-h-96 overflow-y-auto">
|
||||
<MarkdownWrapper className="select-text prose dark:prose-invert">
|
||||
{refinement}
|
||||
</MarkdownWrapper>
|
||||
|
||||
@@ -203,6 +203,7 @@ export const ChatSessionProvider = ({
|
||||
const chain = prompt.pipe(llm);
|
||||
|
||||
setSubmitting(true);
|
||||
const lastChatMessage = chatMessages[chatMessages.length - 1];
|
||||
const reply = await chain.invoke({
|
||||
name: member.agent.name,
|
||||
agent_prompt: member.agent.config.prompt || "",
|
||||
@@ -219,6 +220,7 @@ export const ChatSessionProvider = ({
|
||||
})
|
||||
.join("\n"),
|
||||
history: chatMessages
|
||||
.slice(0, chatMessages.length - 1)
|
||||
.map(
|
||||
(message) =>
|
||||
`- ${(message.member.user || message.member.agent).name}: ${
|
||||
@@ -226,7 +228,10 @@ export const ChatSessionProvider = ({
|
||||
}(${dayjs(message.createdAt).fromNow()})`
|
||||
)
|
||||
.join("\n"),
|
||||
input: chatMessages.length > 0 ? "Continue" : "Start the conversation",
|
||||
input:
|
||||
(lastChatMessage
|
||||
? `${lastChatMessage.member.name}: ${lastChatMessage.content}\n`
|
||||
: "") + `${member.agent.name}:`,
|
||||
});
|
||||
|
||||
// the reply may contain the member's name like "Agent: xxx". We need to remove it.
|
||||
|
||||
1
enjoy/src/types/chat.d.ts
vendored
1
enjoy/src/types/chat.d.ts
vendored
@@ -43,6 +43,7 @@ type ChatMemberType = {
|
||||
introduction?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
name: string;
|
||||
agent?: ChatAgentType;
|
||||
user?: UserType;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user