θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const ScriptTag = ({ embed }) => {
<button
disabled={copied}
onClick={handleClick}
className={`disabled:border disabled:border-green-300 disabled:light:border-green-600 border border-transparent relative w-full font-mono flex hljs ${theme} light:border light:border-gray-700 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5`}
className={`disabled:border disabled:border-green-300 disabled:light:border-green-600 border border-transparent relative w-full font-mono flex hljs ${theme} light:border light:border-gray-700 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5 m-1`}
>
<div
className="flex w-full text-left flex-col gap-y-1 pr-6 pl-4 whitespace-pre-line"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export default function EditEmbedModal({ embed, closeModal }) {
hint="Limit the amount of chats a session user can send with this embed in a 24 hour period. Zero is unlimited."
defaultValue={embed.max_chats_per_session}
/>
<NumberInput
name="message_limit"
title="Message History Limit"
hint="The number of previous messages to include in the chat context. Default is 20."
defaultValue={embed.message_limit}
/>
<BooleanInput
name="allow_model_override"
title="Enable dynamic model use"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function enforceSubmissionSchema(form) {
data.allow_temperature_override = false;
if (!data.hasOwnProperty("allow_prompt_override"))
data.allow_prompt_override = false;
if (!data.hasOwnProperty("message_limit")) data.message_limit = 20;
return data;
}

Expand Down Expand Up @@ -69,6 +70,12 @@ export default function NewEmbedModal({ closeModal }) {
title="Max chats per session"
hint="Limit the amount of chats a session user can send with this embed in a 24 hour period. Zero is unlimited."
/>
<NumberInput
name="message_limit"
title="Message History Limit"
hint="The number of previous messages to include in the chat context. Default is 20."
defaultValue={20}
/>
<BooleanInput
name="allow_model_override"
title="Enable dynamic model use"
Expand Down Expand Up @@ -150,6 +157,7 @@ export const WorkspaceSelection = ({ defaultValue = null }) => {
{workspaces.map((workspace) => {
return (
<option
key={workspace.id}
selected={defaultValue === workspace.id}
value={workspace.id}
>
Expand Down
6 changes: 6 additions & 0 deletions server/models/embedConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const EmbedConfig = {
"max_chats_per_session",
"chat_mode",
"workspace_id",
"message_limit",
],

new: async function (data, creatorId = null) {
Expand Down Expand Up @@ -47,6 +48,10 @@ const EmbedConfig = {
data?.max_chats_per_session,
"max_chats_per_session"
),
message_limit: validatedCreationData(
data?.message_limit,
"message_limit"
),
createdBy: Number(creatorId) ?? null,
workspace: {
connect: { id: Number(data.workspace_id) },
Expand Down Expand Up @@ -190,6 +195,7 @@ const NUMBER_KEYS = [
"max_chats_per_day",
"max_chats_per_session",
"workspace_id",
"message_limit",
];

// Helper to validate a data object strictly into the proper format
Expand Down
2 changes: 2 additions & 0 deletions server/prisma/migrations/20250709230835_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "embed_configs" ADD COLUMN "message_limit" INTEGER DEFAULT 20;
1 change: 1 addition & 0 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ model embed_configs {
allow_prompt_override Boolean @default(false)
max_chats_per_day Int?
max_chats_per_session Int?
message_limit Int? @default(20)
workspace_id Int
createdBy Int?
usersId Int?
Expand Down
2 changes: 1 addition & 1 deletion server/utils/chats/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function streamChatWithForEmbed(
});
const VectorDb = getVectorDbClass();

const messageLimit = 20;
const messageLimit = embed.message_limit ?? 20;
const hasVectorizedSpace = await VectorDb.hasNamespace(embed.workspace.slug);
const embeddingsCount = await VectorDb.namespaceCount(embed.workspace.slug);

Expand Down