Spaces:
Paused
Paused
matt HOFFNER
commited on
Commit
·
64b7c56
1
Parent(s):
c6bfbcd
fix
Browse files
components/Playground/index.tsx
CHANGED
@@ -60,14 +60,22 @@ const Playground = () => {
|
|
60 |
|
61 |
const modifiedHandleSubmit = async (e: FormEvent<HTMLFormElement>, chatRequestOptions?: ChatRequestOptions) => {
|
62 |
e.preventDefault();
|
63 |
-
|
64 |
-
//
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
-
|
|
|
71 |
await handleSubmit(e, chatRequestOptions);
|
72 |
};
|
73 |
|
|
|
60 |
|
61 |
const modifiedHandleSubmit = async (e: FormEvent<HTMLFormElement>, chatRequestOptions?: ChatRequestOptions) => {
|
62 |
e.preventDefault();
|
63 |
+
|
64 |
+
// Step 1: Determine if the system message needs to be appended
|
65 |
+
const hasSystemMessage = messages.some(msg => msg.role === "system");
|
66 |
+
|
67 |
+
// Step 2: Append the system message if required
|
68 |
+
if (!hasSystemMessage) {
|
69 |
+
const systemMessageToAdd: Message = {
|
70 |
+
id: `${Date.now()}-system`,
|
71 |
+
createdAt: new Date(),
|
72 |
+
content: systemMessage,
|
73 |
+
role: "system"
|
74 |
+
};
|
75 |
+
await append(systemMessageToAdd);
|
76 |
}
|
77 |
+
|
78 |
+
// Step 3: Append the user message
|
79 |
await handleSubmit(e, chatRequestOptions);
|
80 |
};
|
81 |
|