in src/azurechat/features/chat/chat-services/chat-thread-service.ts [186:223]
id: uniqueId(),
createdAt: new Date(),
isDeleted: false,
chatType: "simple",
deployment: "",
apiKey: "",
conversationStyle: "precise",
type: CHAT_THREAD_ATTRIBUTE,
chatOverFileName: "",
};
const instance = await CosmosDBContainer.getInstance();
const container = await instance.getContainer();
const response = await container.items.create<ChatThreadModel>(modelToSave);
return response.resource;
};
export const initAndGuardChatSession = async (props: PromptGPTProps) => {
const { messages, id, chatType, deployment, apiKey, conversationStyle, chatOverFileName } = props;
//last message
const lastHumanMessage = messages[messages.length - 1];
const currentChatThread = await EnsureChatThreadIsForCurrentUser(id);
const chats = await FindAllChats(id);
const chatThread = await updateChatThreadTitle(
currentChatThread,
chats,
chatType,
deployment,
apiKey,
conversationStyle,
chatOverFileName,
lastHumanMessage.content
);
return {