-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from openchatai/feat/init_conv
Feat/init conv
- Loading branch information
Showing
15 changed files
with
149 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// original shape | ||
export type Message = { | ||
timestamp?: number; | ||
id: string; | ||
timestamp?: number | Date; | ||
id: string | number; | ||
} & ( | ||
| { from: "user"; content: string } | ||
| ({ from: "bot" } & { | ||
| { from: "user"; content: string } | ||
| ({ from: "bot" } & { | ||
type: "text"; | ||
response: { | ||
text: string; | ||
}; | ||
}) | ||
); | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Message } from "@lib/types" | ||
import { HistoryMessage } from "@lib/types/initialDataType" | ||
|
||
export function historyToMessages(history?: HistoryMessage[]): Message[] { | ||
let $messages: Message[] = [] | ||
if (history) { | ||
history.forEach((m) => { | ||
if (m.from_user) { | ||
$messages.push({ | ||
from: "user", | ||
content: m.message, | ||
id: m.id, | ||
timestamp: new Date(m.created_at), | ||
}) | ||
} else { | ||
$messages.push({ | ||
from: "bot", | ||
id: m.id, | ||
timestamp: new Date(m.created_at), | ||
type: "text", | ||
response: { | ||
text: m.message | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
return $messages | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.