From da9556450f53cfbc6a60317447b4667d98932fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fitcan=20U=C3=87UM?= Date: Mon, 20 Mar 2023 00:09:39 +0300 Subject: [PATCH] feat: add chat completion (#8) * feat: add chat completion * chore: self mutation Signed-off-by: github-actions --------- Signed-off-by: github-actions Co-authored-by: github-actions --- .../conversation-prompt-service.dto.ts | 15 ++ .../conversation-prompt.service.ts | 60 ++++++++ src/conversation-prompt/mention.ts | 4 +- ...ate-conversation-chat-completion-prompt.ts | 27 ++++ .../create-conversation-completion-prompt.ts | 6 +- .../create-conversation-summary-prompt.ts | 2 +- .../prompts/render-ai-persona.ts | 9 +- .../prompts/render-conversation-for-chat.ts | 17 +++ .../prompts/render-format-and-examples.ts | 4 +- ...onversation-chat-completion-prompt.test.ts | 128 ++++++++++++++++++ ...ate-conversation-completion-prompt.test.ts | 53 ++++---- ...create-conversation-summary-prompt.test.ts | 35 +++-- 12 files changed, 308 insertions(+), 52 deletions(-) create mode 100644 src/conversation-prompt/prompts/create-conversation-chat-completion-prompt.ts create mode 100644 src/conversation-prompt/prompts/render-conversation-for-chat.ts create mode 100644 test/conversation-prompt/prompts/create-conversation-chat-completion-prompt.test.ts diff --git a/src/conversation-prompt/conversation-prompt-service.dto.ts b/src/conversation-prompt/conversation-prompt-service.dto.ts index dbabc72..e8d6855 100644 --- a/src/conversation-prompt/conversation-prompt-service.dto.ts +++ b/src/conversation-prompt/conversation-prompt-service.dto.ts @@ -17,6 +17,21 @@ export type ModelConfiguration = Pick< | "frequency_penalty" >; +export type ConversationChatCompleteInput = { + // prompt generation related details + prompt: { + aiPersona: AIPersona; + conversation: Conversation; + }; + modelConfiguration: ModelConfiguration; +}; + +export type ConversationChatCompleteOutput = { + text: string; + usage: APIUsageInfo; + headers: APIResponseHeaders; +}; + export type ConversationCompleteInput = { // prompt generation related details prompt: { diff --git a/src/conversation-prompt/conversation-prompt.service.ts b/src/conversation-prompt/conversation-prompt.service.ts index 740cfb1..7bba5d6 100644 --- a/src/conversation-prompt/conversation-prompt.service.ts +++ b/src/conversation-prompt/conversation-prompt.service.ts @@ -1,15 +1,20 @@ import { + ChatCompletionRequestMessage, + CreateChatCompletionResponse, CreateCompletionResponse, CreateCompletionResponseUsage, OpenAIApi, } from "openai"; import { + ConversationChatCompleteInput, + ConversationChatCompleteOutput, ConversationCompleteInput, ConversationCompleteOutput, ConversationSummaryInput, ConversationSummaryOutput, ModelConfiguration, } from "./conversation-prompt-service.dto"; +import { createConversationChatCompletionPrompt } from "./prompts/create-conversation-chat-completion-prompt"; import { createConversationCompletionPrompt } from "./prompts/create-conversation-completion-prompt"; import { createConversationSummaryPrompt } from "./prompts/create-conversation-summary-prompt"; import { STATEMENT_SEPARATOR_TOKEN } from "./prompts/prompts.constants"; @@ -63,6 +68,23 @@ export class ConversationPromptService { constructor(private readonly openAIApi: OpenAIApi) {} + async chatCompletion( + input: ConversationChatCompleteInput + ): Promise { + const messages = createConversationChatCompletionPrompt(input.prompt); + + const { + firstChoice: text, + usage, + headers, + } = await this.makeChatCompletionRequest({ + messages, + modelConfiguration: input.modelConfiguration, + }); + + return { text, usage, headers }; + } + async completion( input: ConversationCompleteInput ): Promise { @@ -96,6 +118,44 @@ export class ConversationPromptService { return { summary, usage, headers }; } + // TODO: remove duplication + private async makeChatCompletionRequest(input: { + messages: Array; + modelConfiguration: ModelConfiguration; + }) { + try { + const { data, headers }: APIResponse = + await this.openAIApi.createChatCompletion({ + ...input.modelConfiguration, + max_tokens: input.modelConfiguration.max_tokens ?? undefined, + messages: input.messages, + n: 1, + }); + + const firstChoice = data.choices?.[0]?.message?.content?.trim()!; + + return { + firstChoice, + usage: ConversationPromptService.extractAPIUsageInfo(data), + headers: ConversationPromptService.extractAPIResponseHeaders(headers), + }; + } catch (err: unknown) { + if (ConversationPromptService.isErrorResponse(err)) { + const { message, type } = err.response.data.error; + + throw new ConversationPromptServiceError( + err.response.status, + { message, type }, + ConversationPromptService.extractAPIResponseHeaders( + err.response.headers + ) + ); + } + + throw err; + } + } + private async makeCompletionRequest(input: { prompt: string; modelConfiguration: ModelConfiguration; diff --git a/src/conversation-prompt/mention.ts b/src/conversation-prompt/mention.ts index 6c2790c..03991e9 100644 --- a/src/conversation-prompt/mention.ts +++ b/src/conversation-prompt/mention.ts @@ -1,11 +1,11 @@ import { Author } from "../types"; -export const BOT_MENTION = "<@bot>"; +export const ASSISTANT_MENTION = "<@assistant>"; export const buildMention = (author: Author): string => { switch (author.type) { case "BOT": - return BOT_MENTION; + return ASSISTANT_MENTION; case "USER": return `<@${author.id}>`; default: diff --git a/src/conversation-prompt/prompts/create-conversation-chat-completion-prompt.ts b/src/conversation-prompt/prompts/create-conversation-chat-completion-prompt.ts new file mode 100644 index 0000000..fd102a0 --- /dev/null +++ b/src/conversation-prompt/prompts/create-conversation-chat-completion-prompt.ts @@ -0,0 +1,27 @@ +import { ChatCompletionRequestMessage } from "openai"; +import { renderAIPersona } from "./render-ai-persona"; +import { renderConversationForChat } from "./render-conversation-for-chat"; +import { AIPersona, Conversation } from "../../types"; + +const CONVERSATION_SUMMARY_SUFFIX = `The conversations starts with a detailed summary of a previous conversation. While answering questions, take this summary into account. Summary:`; + +export type CreateConversationChatCompletionPromptInput = { + aiPersona: AIPersona; + conversation: Conversation; +}; + +export function createConversationChatCompletionPrompt({ + aiPersona, + conversation, +}: CreateConversationChatCompletionPromptInput): Array { + const systemMessage = { + role: "system" as const, + content: renderAIPersona(aiPersona), + }; + + if (conversation.summary) { + systemMessage.content += `\n\n${CONVERSATION_SUMMARY_SUFFIX} ${conversation.summary}`; + } + + return [systemMessage, ...renderConversationForChat(conversation)]; +} diff --git a/src/conversation-prompt/prompts/create-conversation-completion-prompt.ts b/src/conversation-prompt/prompts/create-conversation-completion-prompt.ts index 0fd9310..a6f8310 100644 --- a/src/conversation-prompt/prompts/create-conversation-completion-prompt.ts +++ b/src/conversation-prompt/prompts/create-conversation-completion-prompt.ts @@ -3,7 +3,7 @@ import { renderAIPersona } from "./render-ai-persona"; import { renderConversation } from "./render-conversation"; import { renderFormatAndExamples } from "./render-format-and-examples"; import { AIPersona, Conversation } from "../../types"; -import { BOT_MENTION } from "../mention"; +import { ASSISTANT_MENTION } from "../mention"; const CURRENT_CONVERSATION_PROMPT = `Continue the conversation, paying very close attention to things entities told you; such as their name, and personal details. Never say "${STATEMENT_SEPARATOR_TOKEN}". Current conversation:`; @@ -22,11 +22,11 @@ export function createConversationCompletionPrompt({ return ( renderAIPersona(aiPersona) + - `\n${renderFormatAndExamples({ + `\n\n${renderFormatAndExamples({ hasSummary, exampleConversations, })}` + `\n\n${CURRENT_CONVERSATION_PROMPT}\n\n` + - (renderConversation(conversation) + `${BOT_MENTION}:`) + (renderConversation(conversation) + `${ASSISTANT_MENTION}:`) ); } diff --git a/src/conversation-prompt/prompts/create-conversation-summary-prompt.ts b/src/conversation-prompt/prompts/create-conversation-summary-prompt.ts index 7c6a899..93502fd 100644 --- a/src/conversation-prompt/prompts/create-conversation-summary-prompt.ts +++ b/src/conversation-prompt/prompts/create-conversation-summary-prompt.ts @@ -53,7 +53,7 @@ export const createConversationSummaryPrompt = ({ return ( renderAIPersona(aiPersona) + - `\n${renderFormatAndExamples({ + `\n\n${renderFormatAndExamples({ hasSummary, })}` + `\n\n${prompt}\n\n` + diff --git a/src/conversation-prompt/prompts/render-ai-persona.ts b/src/conversation-prompt/prompts/render-ai-persona.ts index 80ddb18..734a62e 100644 --- a/src/conversation-prompt/prompts/render-ai-persona.ts +++ b/src/conversation-prompt/prompts/render-ai-persona.ts @@ -1,10 +1,9 @@ import { AIPersona } from "../../types"; -import { BOT_MENTION } from "../mention"; +import { ASSISTANT_MENTION } from "../mention"; export const renderAIPersona = (aiPersona: AIPersona): string => - `Instructions for ${BOT_MENTION}, this is how you should behave in a conversation, but this is not your personality:\n` + - `Your name is "${aiPersona.name}". You are referenced in conversations as "${BOT_MENTION}".\n` + + `Instructions for ${ASSISTANT_MENTION}, this is how you should behave in a conversation, but this is not your personality:\n` + + `Your name is "${aiPersona.name}". You are referenced in conversations as "${ASSISTANT_MENTION}".\n` + aiPersona.instructions + `\n\nThis is your personality:\n` + - aiPersona.personality + - "\n"; + aiPersona.personality; diff --git a/src/conversation-prompt/prompts/render-conversation-for-chat.ts b/src/conversation-prompt/prompts/render-conversation-for-chat.ts new file mode 100644 index 0000000..010cd3d --- /dev/null +++ b/src/conversation-prompt/prompts/render-conversation-for-chat.ts @@ -0,0 +1,17 @@ +import { ChatCompletionRequestMessage } from "openai"; +import { Conversation } from "../../types"; +import { buildMention } from "../mention"; + +export const renderConversationForChat = ({ + messages, +}: Conversation): Array => { + return messages.map((message): ChatCompletionRequestMessage => { + const author = message.author; + + return { + role: author.type === "BOT" ? "assistant" : "user", + name: buildMention(author).replace(/[<>@]/g, ""), + content: message.text, + }; + }); +}; diff --git a/src/conversation-prompt/prompts/render-format-and-examples.ts b/src/conversation-prompt/prompts/render-format-and-examples.ts index 01e0d69..e423355 100644 --- a/src/conversation-prompt/prompts/render-format-and-examples.ts +++ b/src/conversation-prompt/prompts/render-format-and-examples.ts @@ -1,7 +1,7 @@ import { STATEMENT_SEPARATOR_TOKEN } from "./prompts.constants"; import { renderConversation } from "./render-conversation"; import { Conversation } from "../../types"; -import { BOT_MENTION, buildMention } from "../mention"; +import { ASSISTANT_MENTION, buildMention } from "../mention"; const CONVERSATION_FORMAT = `The conversations are in this format, there can be an arbitrary amount of newlines between chat entries. "<@id>" format is used to reference entities in the conversation, where "id" is replaced with message author's unique id. The text "${STATEMENT_SEPARATOR_TOKEN}" is used to separate chat entries and make it easier for you to understand the context:`; const CONVERSATION_FORMAT_WITH_EXAMPLE = `The conversations are in this format, there can be an arbitrary amount of newlines between chat entries. "<@id>" format is used to reference entities in the conversation, where "id" is replaced with message author's unique id. The text "${STATEMENT_SEPARATOR_TOKEN}" is used to separate chat entries and make it easier for you to understand the context. The conversations start with a "Summary:" which includes a detailed summary of messages in the same conversation. Summary ends with "${STATEMENT_SEPARATOR_TOKEN}":`; @@ -22,7 +22,7 @@ const BASIC_EXAMPLE_CONVERSATIONS: Conversation[] = [ { messages: [ { - text: `hello ${BOT_MENTION}`, + text: `hello ${ASSISTANT_MENTION}`, author: { type: "USER", id: "U02" }, }, { diff --git a/test/conversation-prompt/prompts/create-conversation-chat-completion-prompt.test.ts b/test/conversation-prompt/prompts/create-conversation-chat-completion-prompt.test.ts new file mode 100644 index 0000000..b5f3c10 --- /dev/null +++ b/test/conversation-prompt/prompts/create-conversation-chat-completion-prompt.test.ts @@ -0,0 +1,128 @@ +import { + AIPersona, + Author, + ASSISTANT_MENTION, + buildMention, +} from "../../../src"; +import { createConversationChatCompletionPrompt } from "../../../src/conversation-prompt/prompts/create-conversation-chat-completion-prompt"; + +describe("createConversationChatCompletionPrompt", () => { + const aiPersona: AIPersona = { + name: "Lenard", + instructions: `When providing code examples, use triple backticks.`, + personality: `You are a software engineer.`, + }; + const authors: Record = { + bot: { type: "BOT" }, + exampleUser1: { type: "USER", id: "EU01" }, + exampleUser2: { type: "USER", id: "EU02" }, + user1: { type: "USER", id: "U01" }, + }; + + it("should work without summary", () => { + expect( + createConversationChatCompletionPrompt({ + aiPersona, + conversation: { + messages: [ + { + author: authors.user1, + text: "hello!", + }, + { + author: authors.bot, + text: "hello! how can I help you?", + }, + { + author: authors.user1, + text: "can you write me fibonacci function in Typescript?", + }, + ], + }, + }) + ).toMatchInlineSnapshot(` + [ + { + "content": "Instructions for <@assistant>, this is how you should behave in a conversation, but this is not your personality: + Your name is "Lenard". You are referenced in conversations as "<@assistant>". + When providing code examples, use triple backticks. + + This is your personality: + You are a software engineer.", + "role": "system", + }, + { + "content": "hello!", + "name": "U01", + "role": "user", + }, + { + "content": "hello! how can I help you?", + "name": "assistant", + "role": "assistant", + }, + { + "content": "can you write me fibonacci function in Typescript?", + "name": "U01", + "role": "user", + }, + ] + `); + }); + + it("should work with summary", () => { + expect( + createConversationChatCompletionPrompt({ + aiPersona, + conversation: { + summary: `${buildMention( + authors.user1 + )} asked ${ASSISTANT_MENTION} whether it knows Typescript.`, + messages: [ + { + author: authors.user1, + text: "hello!", + }, + { + author: authors.bot, + text: "hello! how can I help you?", + }, + { + author: authors.user1, + text: "can you write me fibonacci function in Typescript?", + }, + ], + }, + }) + ).toMatchInlineSnapshot(` + [ + { + "content": "Instructions for <@assistant>, this is how you should behave in a conversation, but this is not your personality: + Your name is "Lenard". You are referenced in conversations as "<@assistant>". + When providing code examples, use triple backticks. + + This is your personality: + You are a software engineer. + + The conversations starts with a detailed summary of a previous conversation. While answering questions, take this summary into account. Summary: <@U01> asked <@assistant> whether it knows Typescript.", + "role": "system", + }, + { + "content": "hello!", + "name": "U01", + "role": "user", + }, + { + "content": "hello! how can I help you?", + "name": "assistant", + "role": "assistant", + }, + { + "content": "can you write me fibonacci function in Typescript?", + "name": "U01", + "role": "user", + }, + ] + `); + }); +}); diff --git a/test/conversation-prompt/prompts/create-conversation-completion-prompt.test.ts b/test/conversation-prompt/prompts/create-conversation-completion-prompt.test.ts index fc30e47..4a56936 100644 --- a/test/conversation-prompt/prompts/create-conversation-completion-prompt.test.ts +++ b/test/conversation-prompt/prompts/create-conversation-completion-prompt.test.ts @@ -1,4 +1,9 @@ -import { AIPersona, Author, BOT_MENTION, buildMention } from "../../../src"; +import { + AIPersona, + Author, + ASSISTANT_MENTION, + buildMention, +} from "../../../src"; import { createConversationCompletionPrompt } from "../../../src/conversation-prompt/prompts/create-conversation-completion-prompt"; describe("createConversationCompletionPrompt", () => { @@ -70,8 +75,8 @@ describe("createConversationCompletionPrompt", () => { }, }) ).toMatchInlineSnapshot(` - "Instructions for <@bot>, this is how you should behave in a conversation, but this is not your personality: - Your name is "Lenard". You are referenced in conversations as "<@bot>". + "Instructions for <@assistant>, this is how you should behave in a conversation, but this is not your personality: + Your name is "Lenard". You are referenced in conversations as "<@assistant>". When providing code examples, use triple backticks. This is your personality: @@ -80,20 +85,20 @@ describe("createConversationCompletionPrompt", () => { The conversations are in this format, there can be an arbitrary amount of newlines between chat entries. "<@id>" format is used to reference entities in the conversation, where "id" is replaced with message author's unique id. The text "<|endofstatement|>" is used to separate chat entries and make it easier for you to understand the context: <@EU01>: hello <|endofstatement|> - <@bot>: hello <@EU01>. how may I help you? <|endofstatement|> + <@assistant>: hello <@EU01>. how may I help you? <|endofstatement|> <@EU01>: how is it going? <|endofstatement|> - <@bot>: it's fine. thanks for asking. how about you? <|endofstatement|> + <@assistant>: it's fine. thanks for asking. how about you? <|endofstatement|> <@EU02>: hello, friend. <|endofstatement|> - <@bot>: hey there! hello to you too. <|endofstatement|> + <@assistant>: hey there! hello to you too. <|endofstatement|> ... Continue the conversation, paying very close attention to things entities told you; such as their name, and personal details. Never say "<|endofstatement|>". Current conversation: <@U01>: hello! <|endofstatement|> - <@bot>: hello <@U01>! how can I help you? <|endofstatement|> + <@assistant>: hello <@U01>! how can I help you? <|endofstatement|> <@U01>: can you write me fibonacci function in Typescript? <|endofstatement|> - <@bot>:" + <@assistant>:" `); }); }); @@ -121,8 +126,8 @@ describe("createConversationCompletionPrompt", () => { }, }) ).toMatchInlineSnapshot(` - "Instructions for <@bot>, this is how you should behave in a conversation, but this is not your personality: - Your name is "Lenard". You are referenced in conversations as "<@bot>". + "Instructions for <@assistant>, this is how you should behave in a conversation, but this is not your personality: + Your name is "Lenard". You are referenced in conversations as "<@assistant>". When providing code examples, use triple backticks. This is your personality: @@ -131,18 +136,18 @@ describe("createConversationCompletionPrompt", () => { The conversations are in this format, there can be an arbitrary amount of newlines between chat entries. "<@id>" format is used to reference entities in the conversation, where "id" is replaced with message author's unique id. The text "<|endofstatement|>" is used to separate chat entries and make it easier for you to understand the context: <@U01>: [MESSAGE 1] <|endofstatement|> - <@bot>: [RESPONSE TO MESSAGE 1] <|endofstatement|> + <@assistant>: [RESPONSE TO MESSAGE 1] <|endofstatement|> - <@U02>: hello <@bot> <|endofstatement|> - <@bot>: hello <@U02>! how are you? <|endofstatement|> + <@U02>: hello <@assistant> <|endofstatement|> + <@assistant>: hello <@U02>! how are you? <|endofstatement|> ... Continue the conversation, paying very close attention to things entities told you; such as their name, and personal details. Never say "<|endofstatement|>". Current conversation: <@U01>: hello! <|endofstatement|> - <@bot>: hello! how can I help you? <|endofstatement|> + <@assistant>: hello! how can I help you? <|endofstatement|> <@U01>: can you write me fibonacci function in Typescript? <|endofstatement|> - <@bot>:" + <@assistant>:" `); }); @@ -153,7 +158,7 @@ describe("createConversationCompletionPrompt", () => { conversation: { summary: `${buildMention( authors.user1 - )} asked ${BOT_MENTION} whether it knows Typescript.`, + )} asked ${ASSISTANT_MENTION} whether it knows Typescript.`, messages: [ { author: authors.user1, @@ -171,8 +176,8 @@ describe("createConversationCompletionPrompt", () => { }, }) ).toMatchInlineSnapshot(` - "Instructions for <@bot>, this is how you should behave in a conversation, but this is not your personality: - Your name is "Lenard". You are referenced in conversations as "<@bot>". + "Instructions for <@assistant>, this is how you should behave in a conversation, but this is not your personality: + Your name is "Lenard". You are referenced in conversations as "<@assistant>". When providing code examples, use triple backticks. This is your personality: @@ -182,20 +187,20 @@ describe("createConversationCompletionPrompt", () => { Summary: [SUMMARY] <|endofstatement|> <@U01>: [MESSAGE 1] <|endofstatement|> - <@bot>: [RESPONSE TO MESSAGE 1] <|endofstatement|> + <@assistant>: [RESPONSE TO MESSAGE 1] <|endofstatement|> Summary: <@U02> is a Software Engineer named Yigitcan. <|endofstatement|> - <@U02>: hello <@bot> <|endofstatement|> - <@bot>: hello <@U02>! how are you? <|endofstatement|> + <@U02>: hello <@assistant> <|endofstatement|> + <@assistant>: hello <@U02>! how are you? <|endofstatement|> ... Continue the conversation, paying very close attention to things entities told you; such as their name, and personal details. Never say "<|endofstatement|>". Current conversation: - Summary: <@U01> asked <@bot> whether it knows Typescript. <|endofstatement|> + Summary: <@U01> asked <@assistant> whether it knows Typescript. <|endofstatement|> <@U01>: hello! <|endofstatement|> - <@bot>: hello! how can I help you? <|endofstatement|> + <@assistant>: hello! how can I help you? <|endofstatement|> <@U01>: can you write me fibonacci function in Typescript? <|endofstatement|> - <@bot>:" + <@assistant>:" `); }); }); diff --git a/test/conversation-prompt/prompts/create-conversation-summary-prompt.test.ts b/test/conversation-prompt/prompts/create-conversation-summary-prompt.test.ts index 015089b..9a38ceb 100644 --- a/test/conversation-prompt/prompts/create-conversation-summary-prompt.test.ts +++ b/test/conversation-prompt/prompts/create-conversation-summary-prompt.test.ts @@ -1,4 +1,9 @@ -import { AIPersona, Author, BOT_MENTION, buildMention } from "../../../src"; +import { + AIPersona, + Author, + ASSISTANT_MENTION, + buildMention, +} from "../../../src"; import { createConversationSummaryPrompt } from "../../../src/conversation-prompt/prompts/create-conversation-summary-prompt"; describe("createConversationSummaryPrompt()", () => { @@ -34,8 +39,8 @@ describe("createConversationSummaryPrompt()", () => { }, }) ).toMatchInlineSnapshot(` - "Instructions for <@bot>, this is how you should behave in a conversation, but this is not your personality: - Your name is "Lenard". You are referenced in conversations as "<@bot>". + "Instructions for <@assistant>, this is how you should behave in a conversation, but this is not your personality: + Your name is "Lenard". You are referenced in conversations as "<@assistant>". When providing code examples, use triple backticks. This is your personality: @@ -44,16 +49,16 @@ describe("createConversationSummaryPrompt()", () => { The conversations are in this format, there can be an arbitrary amount of newlines between chat entries. "<@id>" format is used to reference entities in the conversation, where "id" is replaced with message author's unique id. The text "<|endofstatement|>" is used to separate chat entries and make it easier for you to understand the context: <@U01>: [MESSAGE 1] <|endofstatement|> - <@bot>: [RESPONSE TO MESSAGE 1] <|endofstatement|> + <@assistant>: [RESPONSE TO MESSAGE 1] <|endofstatement|> - <@U02>: hello <@bot> <|endofstatement|> - <@bot>: hello <@U02>! how are you? <|endofstatement|> + <@U02>: hello <@assistant> <|endofstatement|> + <@assistant>: hello <@U02>! how are you? <|endofstatement|> ... Summarize the conversation below. Make a detailed summary of the existing messages. Do not summarize the instructions or examples. Do not add anything extra or something that was not discussed. Do not repeat details. Pay close attention to the things that entities told you; especially their personal details and code details. Omit small talk and conversation status. Never say "<|endofstatement|>": <@U01>: hello! <|endofstatement|> - <@bot>: hello! how can I help you? <|endofstatement|> + <@assistant>: hello! how can I help you? <|endofstatement|> <@U01>: can you write me fibonacci function in Typescript? <|endofstatement|> ... Summary:" @@ -67,7 +72,7 @@ describe("createConversationSummaryPrompt()", () => { conversation: { summary: `${buildMention( authors.user1 - )} asked ${BOT_MENTION} whether it knows Typescript.`, + )} asked ${ASSISTANT_MENTION} whether it knows Typescript.`, messages: [ { author: authors.user1, @@ -85,8 +90,8 @@ describe("createConversationSummaryPrompt()", () => { }, }) ).toMatchInlineSnapshot(` - "Instructions for <@bot>, this is how you should behave in a conversation, but this is not your personality: - Your name is "Lenard". You are referenced in conversations as "<@bot>". + "Instructions for <@assistant>, this is how you should behave in a conversation, but this is not your personality: + Your name is "Lenard". You are referenced in conversations as "<@assistant>". When providing code examples, use triple backticks. This is your personality: @@ -96,18 +101,18 @@ describe("createConversationSummaryPrompt()", () => { Summary: [SUMMARY] <|endofstatement|> <@U01>: [MESSAGE 1] <|endofstatement|> - <@bot>: [RESPONSE TO MESSAGE 1] <|endofstatement|> + <@assistant>: [RESPONSE TO MESSAGE 1] <|endofstatement|> Summary: <@U02> is a Software Engineer named Yigitcan. <|endofstatement|> - <@U02>: hello <@bot> <|endofstatement|> - <@bot>: hello <@U02>! how are you? <|endofstatement|> + <@U02>: hello <@assistant> <|endofstatement|> + <@assistant>: hello <@U02>! how are you? <|endofstatement|> ... Summarize the conversation below. Make a detailed summary which only consists of the previous summary and later messages. Do not summarize the instructions or examples. Do not add anything extra or something that was not discussed. Do not repeat details. Pay close attention to the things that entities told you; especially their personal details and code details. Omit small talk and conversation status. Never say "<|endofstatement|>": - Summary: <@U01> asked <@bot> whether it knows Typescript. <|endofstatement|> + Summary: <@U01> asked <@assistant> whether it knows Typescript. <|endofstatement|> <@U01>: hello! <|endofstatement|> - <@bot>: hello! how can I help you? <|endofstatement|> + <@assistant>: hello! how can I help you? <|endofstatement|> <@U01>: can you write me fibonacci function in Typescript? <|endofstatement|> ... Summary:"