Skip to content

Instantly share code, notes, and snippets.

@christopherbauer
Created May 18, 2024 16:50
Show Gist options
  • Save christopherbauer/f1cb7d5c6dcb03258f8ef16e558e0062 to your computer and use it in GitHub Desktop.
Save christopherbauer/f1cb7d5c6dcb03258f8ef16e558e0062 to your computer and use it in GitHub Desktop.
import OpenAI from "openai";
import { ChatCompletionMessageParam } from "openai/resources";
import { Message } from "../types";
const openai = new OpenAI({
apiKey: process.env.OPEN_AI_API_KEY,
});
type StorageMessage = OpenAI.Chat.Completions.ChatCompletionMessageParam & {
sent: Date;
};
type ConversationStorageData = { persona: string; messages: StorageMessage[] };
const ConversationStorage: Record<string, ConversationStorageData> = {};
export class ChatGptConversationService {
/* ... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment