Spaces:
Sleeping
Sleeping
Andrew
commited on
Commit
·
78e67be
1
Parent(s):
ddc185d
feat(utils): add legacy conversation converter for tree structure
Browse files
src/lib/utils/tree/convertLegacyConversation.ts
CHANGED
|
@@ -5,8 +5,11 @@ import { v4 } from "uuid";
|
|
| 5 |
export function convertLegacyConversation(
|
| 6 |
conv: Pick<Conversation, "messages" | "rootMessageId" | "preprompt">
|
| 7 |
): Pick<Conversation, "messages" | "rootMessageId" | "preprompt"> {
|
| 8 |
-
if (conv.rootMessageId)
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
const messages = [
|
| 11 |
{
|
| 12 |
from: "system",
|
|
|
|
| 5 |
export function convertLegacyConversation(
|
| 6 |
conv: Pick<Conversation, "messages" | "rootMessageId" | "preprompt">
|
| 7 |
): Pick<Conversation, "messages" | "rootMessageId" | "preprompt"> {
|
| 8 |
+
if (conv.rootMessageId) {
|
| 9 |
+
return conv;
|
| 10 |
+
}
|
| 11 |
+
if (conv.messages.length === 0) return conv;
|
| 12 |
+
|
| 13 |
const messages = [
|
| 14 |
{
|
| 15 |
from: "system",
|