Skip to content

Commit

Permalink
feat: support for new model and multiple simultaneous conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
Peek-A-Booo committed Jun 14, 2023
1 parent 0540903 commit d02eb06
Show file tree
Hide file tree
Showing 33 changed files with 533 additions and 563 deletions.
4 changes: 3 additions & 1 deletion CHANGE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v0.6.1

> 2023-06-13
> 2023-06-14
### Fixed

Expand All @@ -13,6 +13,8 @@

- Added backend capability to calculate token consumption
- Display the total amount of tokens currently consumed at the menu.
- Added support for multiple simultaneous conversations, switching sessions will not break the connection of the current session.
- Added support for the newly updated model from OpenAI: gpt-3.5-turbo-0613/gpt-3.5-turbo-16k

### Changed

Expand Down
4 changes: 3 additions & 1 deletion CHANGE_LOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v0.6.1

> 2023-06-13
> 2023-06-14
### 修复

Expand All @@ -13,6 +13,8 @@

- 新增后端计算 token 消耗的能力
- 新增菜单处显示当前消耗的总 token 数量
- 新增支持多会话同时对话,切换会话时不会断掉当前会话的链接
- 新增支持 openai 刚更新的模型: gpt-3.5-turbo-0613/gpt-3.5-turbo-16k

### 修改

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@radix-ui/react-toast": "1.1.4",
"@react-email/components": "0.0.6",
"@react-email/render": "0.0.7",
"@sentry/nextjs": "7.54.0",
"@sentry/nextjs": "7.55.1",
"@svgr/webpack": "8.0.1",
"@types/node": "20.3.1",
"@types/react": "18.2.12",
Expand Down
149 changes: 56 additions & 93 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/[locale]/(authentication)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cn } from "@/lib";
import Logo from "@/components/site/logo";
import AuthForm from "@/components/authForm";
import AuthForm from "@/components/site/authForm";

export default function Login() {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MobileMenu from "@/components/menu/mobile";
import Setting from "@/components/setting";
import PromptMark from "@/components/prompt/market";
import Navbar from "@/components/navbar";
import Welcome from "@/components/welcome";
import Welcome from "@/components/site/welcome";
import ChatSection from "@/components/chatSection";
import "@/utils/plugin/polyfill-client";

Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(share)/share/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Share } from "@prisma/client";
import { AiOutlineUser } from "react-icons/ai";
import { SiMicrosoftazure } from "react-icons/si";
import Button from "@/components/ui/Button";
import CopyIcon from "@/components/copyIcon";
import CopyIcon from "@/components/site/copyIcon";
import ChatContent from "@/components/chatContent";
import BasicInfo from "@/components/share/basicInfo";
import NotFound from "@/components/share/notFound";
Expand Down
13 changes: 2 additions & 11 deletions src/app/api/azure/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { headers } from "next/headers";
import { NextResponse } from "next/server";
import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { isUndefined } from "@/lib";
import { GPTTokens } from "@/lib/gpt-tokens";
import { isUndefined, calcTokens } from "@/lib";
import type { supportModelType } from "@/lib/gpt-tokens";
import { prisma } from "@/lib/prisma";

Expand Down Expand Up @@ -70,8 +69,7 @@ const stream = async (
if (userId) {
const final = [...messages, { role: "assistant", content: resultContent }];

const tokenInfo = new GPTTokens({ model, messages: final });
const { usedTokens, usedUSD } = tokenInfo;
const { usedTokens, usedUSD } = calcTokens(final, model);

const findUser = await prisma.user.findUnique({
where: { id: userId },
Expand Down Expand Up @@ -171,13 +169,6 @@ export async function POST(request: Request) {
session?.user.id
);

if (session) {
await prisma.user.update({
data: { recentlyUse: new Date() },
where: { id: session?.user.id },
});
}

return new Response(readable, response);
} catch (error: any) {
console.log(error, "azure error");
Expand Down
Loading

1 comment on commit d02eb06

@vercel
Copy link

@vercel vercel bot commented on d02eb06 Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.