Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
glsk-ai-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5699dbc5
authored
Apr 29, 2025
by
杨明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
域名
1 parent
3b64d862
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
184 additions
and
125 deletions
Dockerfile
app/components/base/answer-icon/index.tsx
app/components/base/button/index.css
app/components/base/button/index.tsx
app/components/base/chat/chat-with-history/chat-wrapper.tsx
app/components/base/chat/chat-with-history/hooks.tsx
app/components/base/chat/chat-with-history/index.tsx
app/components/base/chat/chat/answer/suggested-questions.tsx
app/components/base/chat/chat/chat-input-area/index.tsx
app/components/base/chat/chat/chat-input-area/operation.tsx
app/components/base/chat/chat/index.tsx
app/components/base/chat/constants.ts
config/index.ts
themes/light.css
Dockerfile
View file @
5699dbc
# base image
FROM
node:20-alpine3.20 AS base
LABEL maintainer="
takatost@gmail.com
"
LABEL maintainer="
yangming@didihu.com.cn
"
# if you located in China, you can use aliyun mirror to speed up
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN
sed -i
's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g'
/etc/apk/repositories
RUN
apk add --no-cache tzdata
RUN
npm install -g pnpm@9.12.2
ENV
PNPM_HOME="/pnpm"
...
...
@@ -51,14 +52,13 @@ ENV MARKETPLACE_URL=http://192.168.3.241
ENV
PORT=3000
ENV
NEXT_TELEMETRY_DISABLED=1
ENV
PM2_INSTANCES=2
# set timezone
ENV
TZ=UTC
#ENV TZ=UTC
ENV
TZ=Asia/Shanghai
RUN
ln -s /usr/share/zoneinfo/
${
TZ
}
/etc/localtime
\
&&
echo
${
TZ
}
> /etc/timezone
...
...
app/components/base/answer-icon/index.tsx
View file @
5699dbc
...
...
@@ -2,7 +2,7 @@
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-2
4 09:45:21
* @LastEditTime: 2025-04-2
8 13:55:48
* @FilePath: \glsk-ai-assistant\app\components\base\answer-icon\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -35,15 +35,10 @@ const AnswerIcon: FC<AnswerIconProps> = ({
"w-full",
"h-full",
"rounded-full",
"border-[0.5px]",
"border-black/5",
"text-xl"
);
return (
<div
className={wrapperClassName}
style={{ background: background || "#D5F5F6" }}
>
<div className={wrapperClassName}>
<img
src={imageUrl}
className="h-full w-full rounded-full"
...
...
app/components/base/button/index.css
View file @
5699dbc
...
...
@@ -93,13 +93,11 @@
.btn-secondary-accent
{
@apply
border-[0.5px]
shadow-xs
bg-components-button-secondary-bg
border-components-button-secondary-border
hover
:
bg-components-button-secondary-bg-hover
border-[0px]
hover
:
border-components-button-secondary-border-hover
text-components-button-secondary-accent-text
;
background
:
#f5f8fc
;
color
:
#383A3D
;
}
.btn-secondary-accent.btn-disabled
{
...
...
@@ -183,4 +181,12 @@
@apply
text-components-button-secondary-accent-text-disabled;
}
}
\ No newline at end of file
.arrow-icon
{
margin-left
:
10px
;
width
:
8px
;
height
:
8px
;
border-top
:
1.5px
solid
#969BA3
;
border-right
:
1.5px
solid
#969BA3
;
transform
:
rotate
(
45deg
);
}
}
app/components/base/button/index.tsx
View file @
5699dbc
import type { CSSProperties } from
'react'
import React from
'react'
import { type VariantProps, cva } from
'class-variance-authority'
import Spinner from
'../spinner'
import classNames from
'@/utils/classnames'
import type { CSSProperties } from
"react";
import React from
"react";
import { type VariantProps, cva } from
"class-variance-authority";
import Spinner from
"../spinner";
import classNames from
"@/utils/classnames";
const buttonVariants = cva(
'btn disabled:btn-disabled',
{
variants: {
variant: {
'primary': 'btn-primary',
'warning': 'btn-warning',
'secondary': 'btn-secondary',
'secondary-accent': 'btn-secondary-accent',
'ghost': 'btn-ghost',
'ghost-accent': 'btn-ghost-accent',
'tertiary': 'btn-tertiary',
},
size: {
small: 'btn-small',
medium: 'btn-medium',
large: 'btn-large',
},
const buttonVariants = cva("btn disabled:btn-disabled", {
variants: {
variant: {
primary: "btn-primary",
warning: "btn-warning",
secondary: "btn-secondary",
"secondary-accent": "btn-secondary-accent",
ghost: "btn-ghost",
"ghost-accent": "btn-ghost-accent",
tertiary: "btn-tertiary",
},
defaultVariants: {
variant: 'secondary',
size: 'medium',
size: {
small: "btn-small",
medium: "btn-medium",
large: "btn-large",
},
},
)
defaultVariants: {
variant: "secondary",
size: "medium",
},
});
export type ButtonProps = {
destructive?: boolean
loading?: boolean
styleCss?: CSSProperties
spinnerClassName?: string
} & React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants>
destructive?: boolean;
loading?: boolean;
styleCss?: CSSProperties;
showArrow?: boolean;
spinnerClassName?: string;
} & React.ButtonHTMLAttributes<HTMLButtonElement> &
VariantProps<typeof buttonVariants>;
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, destructive, loading, styleCss, children, spinnerClassName, ...props }, ref) => {
(
{
className,
variant,
size,
destructive,
loading,
styleCss,
showArrow,
children,
spinnerClassName,
...props
},
ref
) => {
return (
<button
type=
'button'
type=
"button"
className={classNames(
buttonVariants({ variant, size, className }),
destructive &&
'btn-destructive',
destructive &&
"btn-destructive"
)}
ref={ref}
style={styleCss}
{...props}
>
{children}
{loading && <Spinner loading={loading} className={classNames('!text-white !h-3 !w-3 !border-2 !ml-1', spinnerClassName)} />}
{loading && (
<Spinner
loading={loading}
className={classNames(
"!text-white !h-3 !w-3 !border-2 !ml-1",
spinnerClassName
)}
/>
)}
{showArrow &&<span className="arrow-icon"></span>}
</button>
)
}
,
)
Button.displayName =
'Button'
)
;
}
)
;
Button.displayName =
"Button";
export default Button
export { Button, buttonVariants }
export default Button
;
export { Button, buttonVariants }
;
app/components/base/chat/chat-with-history/chat-wrapper.tsx
View file @
5699dbc
...
...
@@ -2,7 +2,7 @@
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-2
5 14:46:27
* @LastEditTime: 2025-04-2
8 10:51:44
* @FilePath: \glsk-ai-assistant\app\components\base\chat\chat-with-history\chat-wrapper.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -29,8 +29,9 @@ import { SELF_INPUT } from "@/app/components/base/chat/constants";
type Props = {
avatar: string;
aiAvatar: string;
doClear?: () => void;
};
const ChatWrapper = ({ avatar, aiAvatar }: Props) => {
const ChatWrapper = ({ avatar, aiAvatar
, doClear
}: Props) => {
const {
appParams,
appPrevChatTree,
...
...
@@ -54,6 +55,7 @@ const ChatWrapper = ({ avatar, aiAvatar }: Props) => {
setClearChatList,
setIsResponding,
} = useChatWithHistoryContext();
const appConfig = useMemo(() => {
const config = appParams || {};
...
...
@@ -138,7 +140,6 @@ const ChatWrapper = ({ avatar, aiAvatar }: Props) => {
useEffect(() => {
setIsResponding(respondingState);
}, [respondingState, setIsResponding]);
const doSend: OnSend = useCallback(
(
messageObj,
...
...
@@ -293,6 +294,7 @@ const ChatWrapper = ({ avatar, aiAvatar }: Props) => {
isMobile ? "px-2" : "px-4"
}`}
onSend={doSend}
onClear={doClear}
inputs={
currentConversationId
? (currentConversationInputs as any)
...
...
app/components/base/chat/chat-with-history/hooks.tsx
View file @
5699dbc
...
...
@@ -414,11 +414,11 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
[handleConversationIdInfoChange, setClearChatList]
);
const handleNewConversation = useCallback(
(inputs?: Record<string, any>) => {
(inputs?: Record<string, any>
,isReset?:boolean
) => {
currentChatInstanceRef.current.handleStop();
setShowNewConversationItemInList(true);
handleChangeConversation("");
handleNewConversationInputsChange(inputs || {});
!isReset &&
handleNewConversationInputsChange(inputs || {});
setClearChatList(true);
},
[
...
...
app/components/base/chat/chat-with-history/index.tsx
View file @
5699dbc
import type { FC } from "react";
import { useEffect, useState } from "react";
import { useEffect, useState
, useCallback
} from "react";
import { useAsyncEffect } from "ahooks";
import { useThemeContext } from "../embedded-chatbot/theme/theme-context";
import { ChatWithHistoryContext, useChatWithHistoryContext } from "./context";
...
...
@@ -22,6 +22,7 @@ type ChatWithHistoryProps = {
className?: string;
};
type urlProps = {
no_header?: string; // 是否显示头部
avatar?: string; // 头像
business_type?: string; // 业务类型
brand?: string; // 品牌
...
...
@@ -53,8 +54,15 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
appChatListDataLoading,
chatShouldReloadKey,
isMobile,
handleNewConversation,
handleNewConversationInputsChange
} = useChatWithHistoryContext();
const doClear = useCallback(() => {
handleNewConversation();
setTimeout(() => {
handleNewConversationInputsChange(newInputs);
}, 300);
}, [handleNewConversation]);
if (appInfoLoading) {
return <Loading type="app" />;
}
...
...
@@ -79,9 +87,12 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
"flex h-full flex-col overflow-hidden border-components-panel-border-subtle chat-panel-bg"
)}
>
<Header avatar={avatar} title={MAIN_TITLE} />
{!newInputs.no_header && (
<Header avatar={avatar} title={MAIN_TITLE} />
)}
{!appChatListDataLoading && (
<ChatWrapper
doClear={doClear}
key={chatShouldReloadKey}
avatar={avatar}
aiAvatar={AVATAR_AI_URL}
...
...
@@ -146,8 +157,9 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
} = useChatWithHistory(installedAppInfo);
useEffect(() => {
//新建对话
handleNewConversation()
setTimeout(() => {
handleNewConversation(newInputs);
handleNewConversation
InputsChange
(newInputs);
}, 1000);
}, []);
return (
...
...
app/components/base/chat/chat/answer/suggested-questions.tsx
View file @
5699dbc
import type { FC } from 'react'
import { memo } from 'react'
import type { ChatItem } from '../../types'
import { useChatContext } from '../context'
import Button from '@/app/components/base/button'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import {AUTO_INPUT} from "@/app/components/base/chat/constants";
/*
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-28 10:10:51
* @FilePath: \glsk-ai-assistant\app\components\base\chat\chat\answer\suggested-questions.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import type { FC } from "react";
import { memo } from "react";
import type { ChatItem } from "../../types";
import { useChatContext } from "../context";
import Button from "@/app/components/base/button";
import useBreakpoints, { MediaType } from "@/hooks/use-breakpoints";
import { AUTO_INPUT } from "@/app/components/base/chat/constants";
type SuggestedQuestionsProps = {
item: ChatItem
}
const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({
item,
}) => {
const
{ onSend } = useChatContext()
const
media = useBreakpoints()
const isMobile = media === MediaType.mobile
const klassName = `mr-1 mt-1 ${isMobile ? 'block overflow-hidden text-ellipsis' : ''} max-w-full shrink-0 last:mr-0`
item: ChatItem
;
}
;
const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({
item }) => {
const { onSend } = useChatContext();
const media = useBreakpoints();
const
isMobile = media === MediaType.mobile;
const
klassName = `mr-1 mt-3 ${
isMobile ? "block overflow-hidden text-ellipsis" : ""
} max-w-full shrink-0 last:mr-0`;
const {
suggestedQuestions,
} = item
if (!suggestedQuestions?.length)
return null
const { suggestedQuestions } = item;
if (!suggestedQuestions?.length) return null;
return (
<div className='flex flex-wrap'>
{suggestedQuestions.filter(q => !!q && q.trim()).map((question, index) => (
<Button
key={index}
variant='secondary-accent'
className={klassName}
onClick={() => onSend?.({message:question,type:AUTO_INPUT})}
>
{question}
</Button>),
)}
<div className="flex flex-wrap">
{suggestedQuestions
.filter((q) => !!q && q.trim())
.map((question, index) => (
<Button
key={index}
variant="secondary-accent"
showArrow={true}
className={klassName}
onClick={() => onSend?.({ message: question, type: AUTO_INPUT })}
>
{question}
</Button>
))}
</div>
)
}
)
;
}
;
export default memo(SuggestedQuestions)
export default memo(SuggestedQuestions)
;
app/components/base/chat/chat/chat-input-area/index.tsx
View file @
5699dbc
...
...
@@ -20,7 +20,11 @@ import { useToastContext } from "@/app/components/base/toast";
import FeatureBar from "@/app/components/base/features/new-feature-panel/feature-bar";
import type { FileUpload } from "@/app/components/base/features/types";
import { TransferMethod } from "@/types/app";
import { SELF_INPUT } from "@/app/components/base/chat/constants";
import {
SELF_INPUT,
SEND_BUTTON,
CLEAR_BUTTON,
} from "@/app/components/base/chat/constants";
type ChatInputAreaProps = {
showFeatureBar?: boolean;
showFileUpload?: boolean;
...
...
@@ -29,6 +33,7 @@ type ChatInputAreaProps = {
visionConfig?: FileUpload;
speechToTextConfig?: EnableType;
onSend?: OnSend;
onClear?: () => void;
inputs?: Record<string, any>;
inputsForm?: InputForm[];
theme?: Theme | null;
...
...
@@ -43,6 +48,7 @@ const ChatInputArea = ({
visionConfig,
speechToTextConfig = { enabled: true },
onSend,
onClear,
inputs = {},
inputsForm = [],
theme,
...
...
@@ -112,6 +118,11 @@ const ChatInputArea = ({
// }
}
};
const handleClear = () => {
if (onClear) {
onClear();
}
};
const handleCompositionStart = () => {
// e: React.CompositionEvent<HTMLTextAreaElement>
isComposingRef.current = true;
...
...
@@ -179,10 +190,13 @@ const ChatInputArea = ({
speechToTextConfig={speechToTextConfig}
onShowVoiceInput={handleShowVoiceInput}
onSend={handleSend}
imgUrl={SEND_BUTTON}
theme={theme}
/>
);
const clear = (
<Operation ref={holdSpaceRef} onSend={handleClear} imgUrl={CLEAR_BUTTON} />
);
return (
<>
<div
...
...
@@ -196,6 +210,7 @@ const ChatInputArea = ({
<FileListInChatInput fileConfig={visionConfig!} />
<div ref={wrapperRef} className="flex items-center justify-between">
<div className="relative flex w-full grow items-center">
{clear}
<div
ref={textValueRef}
className="body-lg-regular pointer-events-none invisible absolute h-auto w-auto whitespace-pre p-1 leading-6"
...
...
app/components/base/chat/chat/chat-input-area/operation.tsx
View file @
5699dbc
...
...
@@ -13,15 +13,13 @@ type OperationProps = {
speechToTextConfig?: EnableType;
onShowVoiceInput?: () => void;
onSend: () => void;
imgUrl?: string;
theme?: Theme | null;
};
const Operation = ({
ref,
fileConfig,
speechToTextConfig,
onShowVoiceInput,
onSend,
theme
,
imgUrl
,
}: OperationProps & {
ref: React.RefObject<HTMLDivElement>;
}) => {
...
...
@@ -41,20 +39,14 @@ const Operation = ({
)
}
</div> */}
<Button
className="ml-3 w-8 px-0"
variant="primary"
onClick={onSend}
style={
theme
? {
backgroundColor: theme.primaryColor,
}
: {}
}
>
<RiSendPlane2Fill className="h-4 w-4" />
</Button>
{imgUrl && (
<img
onClick={onSend}
src={imgUrl}
className="size-6 hover:cursor-pointer"
alt="icon"
/>
)}
</div>
</div>
);
...
...
app/components/base/chat/chat/index.tsx
View file @
5699dbc
...
...
@@ -35,6 +35,7 @@ export type ChatProps = {
onStopResponding?: () => void;
noChatInput?: boolean;
onSend?: OnSend;
onClear?: () => void;
inputs?: Record<string, any>;
inputsForm?: InputForm[];
onRegenerate?: OnRegenerate;
...
...
@@ -80,6 +81,7 @@ const Chat: FC<ChatProps> = ({
appData,
config,
onSend,
onClear,
inputs,
inputsForm,
onRegenerate,
...
...
@@ -314,7 +316,7 @@ const Chat: FC<ChatProps> = ({
<Button onClick={onStopResponding}>
<StopCircle className="mr-[5px] h-3.5 w-3.5 text-gray-500" />
<span className="text-xs font-normal text-gray-500">
{t("
appDebug.operation.stopResponding
")}
{t("
停止响应
")}
</span>
</Button>
</div>
...
...
@@ -336,6 +338,7 @@ const Chat: FC<ChatProps> = ({
visionConfig={config?.file_upload}
speechToTextConfig={config?.speech_to_text}
onSend={onSend}
onClear={onClear}
inputs={inputs}
inputsForm={inputsForm}
theme={themeBuilder?.theme}
...
...
app/components/base/chat/constants.ts
View file @
5699dbc
...
...
@@ -8,3 +8,7 @@ export const AVATAR_USER_URL =
export
const
MAIN_TITLE
=
"广联AI集市"
;
export
const
SELF_INPUT
=
"0"
;
export
const
AUTO_INPUT
=
"1"
;
export
const
SEND_BUTTON
=
"https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-send.png"
;
export
const
CLEAR_BUTTON
=
"https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-clear.png"
;
config/index.ts
View file @
5699dbc
This diff is collapsed.
Click to expand it.
themes/light.css
View file @
5699dbc
...
...
@@ -740,4 +740,4 @@ html[data-theme="light"] {
url("https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-bg.png")
top
/
100%
240px
no-repeat
,
#f5f9ff
0
240px
/
100%
calc
(
100%
-
240px
)
no-repeat
;
}
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment