projects > openai_chat.ts
1
Openai Chat[github][live]
1
2
ChatGPT clone using the T3 Stack, which includes Next.js,
3
TypeScript, Tailwind CSS, and tRPC.
4
5
The repo provides a structured foundation for creating a modern
6
web application, integrating technologies like Prisma for
7
database management and NextAuth.js for authentication.
8
9
[Neon][Next.js][Node.js][OpenAI][PostgreSQL][Prisma][React][TanStack][TypeScript][Vercel][t3.gg][tRPC]
10
12
13
async makeTitle(history: Message[]): Promise<string> {
14
const input = {
15
role: "user",
16
content:
17
"Make a title for this chat which consist of few words, no quotes",
18
} as Message;
19
const res = await openai.chat.completions.create({
20
model: this.model,
21
messages: [
22
...history,
23
{ ...input, content: `${input.content}\n---${this.constraints}\n---` },
24
],
25
});
26
const outputContent = res?.choices[0]?.message?.content ?? "";
27
return outputContent;
28
}
29
30
31
32
33
34
35
NORMAL~/oleksandr/projects/openai_chat.ts.../projects/openai_chat.tsmainutf-8
Enter to open · :q to quit
keys
j / kmove the cursor line, or the tree cursor
hfocus the tree; in the tree, fold or go to the parent
l / Enterin the tree, unfold or open the file
gg / Gfirst / last line
clickput the cursor on a line; on README.sh, run the session again
:qquit to the shell
:help ?this table
q / Escclose this