Last active
May 18, 2024 17:12
-
-
Save christopherbauer/cdc40ee7800003f5b3d71c72bb9446a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| export class ChatGptConversationService { | |
| /* ... */ | |
| getConversation = (id: string) => | |
| Promise.resolve( | |
| ConversationStorage[id]?.messages | |
| .filter((m) => m.role !== "system") | |
| .map<Message>((m) => ({ | |
| text: String(m.content), | |
| sent: m.sent, | |
| source: m.role === "user" ? "user" : "bot", | |
| })) | |
| ); | |
| /* ... */ | |
| } | |
| export class InMemoryConversationService implements ConversationService { | |
| /* ... */ | |
| getConversation = async (id: string): Promise<Conversation> => { | |
| const messages = await this.chatgpt.getConversation(id); | |
| if (!messages) { | |
| return []; | |
| } | |
| return messages; | |
| }; | |
| /* ... */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment