Spaces:
Paused
Paused
matt HOFFNER
commited on
Commit
·
2594151
1
Parent(s):
6bd9e2b
fix system message attempt
Browse files
components/Playground/index.tsx
CHANGED
|
@@ -67,10 +67,11 @@ const Playground = () => {
|
|
| 67 |
},
|
| 68 |
});
|
| 69 |
|
| 70 |
-
const modifiedHandleSubmit = async (e:
|
| 71 |
e.preventDefault();
|
| 72 |
|
| 73 |
-
|
|
|
|
| 74 |
const systemMessageToAdd: Message = {
|
| 75 |
id: `${Date.now()}-system`,
|
| 76 |
createdAt: new Date(),
|
|
@@ -79,13 +80,11 @@ const Playground = () => {
|
|
| 79 |
};
|
| 80 |
await append(systemMessageToAdd);
|
| 81 |
}
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
useEffect(() => {
|
| 90 |
if (!esbuildStatus.isReady) {
|
| 91 |
dispatch(initEsbuild());
|
|
|
|
| 67 |
},
|
| 68 |
});
|
| 69 |
|
| 70 |
+
const modifiedHandleSubmit = async (e: FormEvent<HTMLFormElement>, chatRequestOptions?: ChatRequestOptions) => {
|
| 71 |
e.preventDefault();
|
| 72 |
|
| 73 |
+
// If the first message is not a system message, append the system message
|
| 74 |
+
if (messages.length === 0 || (messages.length > 0 && messages[0].role !== "system")) {
|
| 75 |
const systemMessageToAdd: Message = {
|
| 76 |
id: `${Date.now()}-system`,
|
| 77 |
createdAt: new Date(),
|
|
|
|
| 80 |
};
|
| 81 |
await append(systemMessageToAdd);
|
| 82 |
}
|
| 83 |
+
|
| 84 |
+
// Now handle the user's message
|
| 85 |
+
await handleSubmit(e, chatRequestOptions);
|
| 86 |
+
};
|
| 87 |
+
|
|
|
|
|
|
|
| 88 |
useEffect(() => {
|
| 89 |
if (!esbuildStatus.isReady) {
|
| 90 |
dispatch(initEsbuild());
|