Created
July 24, 2024 16:50
-
-
Save hamstu/c0bf04270ef40b7b879516d5e2e0a36d 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 async function summarizeThread( | |
thread: Thread, | |
authorName: string | |
): Promise<CreateChatCompletionResponse> { | |
const allTextFromThread = thread.blocks | |
.map((block) => block.plaintext) | |
.join("\n"); | |
const openai = await OpenAI.getClient(); | |
const completion = await openai.createChatCompletion({ | |
model: "gpt-3.5-turbo", | |
messages: [ | |
{ | |
role: "user", | |
content: ` | |
The following is a thread written by ${ | |
authorName.split(" ")[0] | |
}. Write a concise and short summary of the thread using the following Markdown format and syntax. | |
Don't write paragraphs, just short bullet points. Write it in third person plural, and make it more personal by referring to others as team members. Limit the summary to a maximum of 2 bullet points. The ">" character should be included in the output before each "•". | |
> • <Summary bullet point 1> | |
> • <Summary bullet point 2> | |
... | |
${allTextFromThread} | |
`, | |
}, | |
], | |
temperature: 0, | |
}); | |
return completion.data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment