Merge remote-tracking branch 'origin/main' into dev

This commit is contained in:
sijinhui 2024-09-27 13:05:38 +08:00
commit f8cac63d1e
11 changed files with 99 additions and 33 deletions

View File

@ -28,6 +28,13 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: cache.Dockerfile
file: cache.install.Dockerfile
push: true
tags: sijinhui/chatgpt-next-web:installcache
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: cache.build.Dockerfile
push: true
tags: sijinhui/chatgpt-next-web:buildcache

View File

@ -1,27 +1,36 @@
FROM sijinhui/chatgpt-next-web:buildcache AS deps
#FROM sijinhui/chatgpt-next-web:installcache AS deps
#
#WORKDIR /app
#
#COPY package.json yarn.lock ./
#
#RUN yarn install
#
#FROM sijinhui/node:base AS builder
#
#RUN apk add --no-cache git libc6-compat
#
#ENV OPENAI_API_KEY=""
#ENV GOOGLE_API_KEY=""
#ENV CODE=""
#
#WORKDIR /app
#COPY . .
#COPY --from=deps /app/node_modules ./node_modules
## 避免下面那个报错
## RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
## RUN yarn add sharp
## ENV NEXT_SHARP_PATH /app/node_modules/sharp
#RUN yarn build
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install
FROM sijinhui/chatgpt-next-web:buildcache as base
FROM sijinhui/node:base AS builder
RUN apk add --no-cache git libc6-compat
ENV OPENAI_API_KEY=""
ENV GOOGLE_API_KEY=""
ENV CODE=""
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
# 避免下面那个报错
# RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
# RUN yarn add sharp
# ENV NEXT_SHARP_PATH /app/node_modules/sharp
RUN yarn build
COPY --from=base /app/.next ./next
COPY --from=base /app/node_modules ./node_modules
RUN yarn install && yarn build
FROM sijinhui/node:base AS runner
WORKDIR /app

View File

@ -22,7 +22,7 @@ import { useMobileScreen } from "../utils";
// motion
import QueueAnim from "rc-queue-anim";
export function ChatItem(props: {
function ChatItem(props: {
onClick?: () => void;
onDelete?: () => void;
title: string;
@ -34,6 +34,7 @@ export function ChatItem(props: {
narrow?: boolean;
mask: Mask;
provided: DraggableProvided;
isMobileScreen: boolean;
}) {
const draggableRef = useRef<HTMLDivElement | null>(null);
useEffect(() => {
@ -57,8 +58,8 @@ export function ChatItem(props: {
draggableRef.current = ele;
props.provided.innerRef(ele);
}}
{...props.provided.draggableProps}
{...props.provided.dragHandleProps}
{...(props.isMobileScreen ? {} : props.provided.draggableProps)}
{...(props.isMobileScreen ? {} : props.provided.dragHandleProps)}
title={`${props.title}\n${Locale.ChatItem.ChatItemCount(props.count)}`}
>
{props.narrow ? (
@ -84,7 +85,10 @@ export function ChatItem(props: {
)}
<div
className={styles["chat-item-delete"]}
className={
styles["chat-item-delete"] +
` ${props.isMobileScreen ? styles["chat-item-delete-visible"] : ""}`
}
onClickCapture={(e) => {
props.onDelete?.();
e.preventDefault();
@ -155,6 +159,7 @@ export function ChatList(props: { narrow?: boolean }) {
narrow={props.narrow}
mask={sessions[rubic.source.index].mask}
provided={provided}
isMobileScreen={isMobileScreen}
/>
)}
>
@ -167,13 +172,16 @@ export function ChatList(props: { narrow?: boolean }) {
<QueueAnim
delay={[100, 0]}
ease={"easeOutQuart"} // "easeInOutQuart"
duration={[550, 450]}
duration={[350, 450]}
animConfig={[
{ opacity: [1, 0], translateY: [0, -30] },
{ opacity: [1, 0], translateY: [0, -30], height: [71, 0] },
{ height: 0 },
]}
// TODO目前仅剩添加元素其他元素平移动画问题
// interval={150}
// TODO手机端好像还有点问题,先把拖拽关了
onEnd={({ key, type, target }) => {
if (type === "enter") target.style.height = "auto";
}}
interval={50}
>
{sessions.map((item, i) => (
<div key={item.id}>
@ -202,6 +210,7 @@ export function ChatList(props: { narrow?: boolean }) {
narrow={props.narrow}
mask={item.mask}
provided={provided}
isMobileScreen={isMobileScreen}
/>
)}
</Draggable>

View File

@ -229,6 +229,13 @@
opacity: 1;
}
/* 新增类,按钮持续显示 */
.chat-item > .chat-item-delete-visible {
opacity: 0.5;
transform: translateX(-4px);
}
.chat-item-info {
display: flex;
justify-content: space-between;

View File

@ -434,7 +434,7 @@ export const DEFAULT_MODELS = [
// },
// },
{
name: "o1-preview-all",
name: "o1-preview",
describe: "GPT,o1,最新模型,目前较贵",
available: true,
sorted: seq++,

View File

@ -182,7 +182,7 @@ export const useAppConfig = createPersistStore(
}),
{
name: StoreKey.Config,
version: 4.1,
version: 4.2,
merge(persistedState, currentState) {
const state = persistedState as ChatConfig | undefined;
@ -229,7 +229,7 @@ export const useAppConfig = createPersistStore(
state.lastUpdate = Date.now();
}
if (version < 4.1) {
if (version < 4.2) {
state.modelConfig.compressModel =
DEFAULT_CONFIG.modelConfig.compressModel;
state.modelConfig.compressProviderName =

18
cache.build.Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM sijinhui/chatgpt-next-web:installcache AS deps
FROM sijinhui/node:base AS builder
RUN apk add --no-cache git libc6-compat
ENV OPENAI_API_KEY=""
ENV GOOGLE_API_KEY=""
ENV CODE=""
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
# 避免下面那个报错
# RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
# RUN yarn add sharp
# ENV NEXT_SHARP_PATH /app/node_modules/sharp
RUN yarn build

12
ecosystem.config.js Normal file
View File

@ -0,0 +1,12 @@
module.exports = {
apps : [{
name : "chat",
script : "yarn",
args : "start",
env : {
PORT : 23000
},
autorestart: true,
interpreter: '/bin/bash',
}]
}

View File

@ -86,7 +86,11 @@ const nextConfig = {
},
experimental: {
forceSwcTransforms: true,
serverComponentsExternalPackages: ["tiktoken"]
serverComponentsExternalPackages: ["tiktoken"],
// 加速跟踪依赖项
// turbotrace: {
// logDetail: true,
// },
},
// externals: {
// 'sharp': 'commonjs sharp'

View File

@ -1,4 +1,4 @@
FROM hub.si.icu/library/node:22.1-alpine AS base
FROM node:22.1-alpine AS base
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache tzdata
# 设置时区环境变量