Skip to content

Commit 1df62f4

Browse files
authored
Merge branch 'main' into chore/update-nextjs
2 parents 65f90f5 + 0ddaa92 commit 1df62f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3114
-274
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Conversion Web App Template
1+
# Conversation Web App Template
22
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
33

44
## Config App
@@ -8,6 +8,8 @@ Create a file named `.env.local` in the current directory and copy the contents
88
NEXT_PUBLIC_APP_ID=
99
# APP API key
1010
NEXT_PUBLIC_APP_KEY=
11+
# APP URL
12+
NEXT_PUBLIC_API_URL=
1113
```
1214

1315
Config more in `config/index.ts` file:

app/api/chat-messages/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ export async function POST(request: NextRequest) {
66
const {
77
inputs,
88
query,
9+
files,
910
conversation_id: conversationId,
1011
response_mode: responseMode,
1112
} = body
1213
const { user } = getInfo(request)
13-
const res = await client.createChatMessage(inputs, query, user, responseMode, conversationId)
14+
const res = await client.createChatMessage(inputs, query, user, responseMode, conversationId, files)
1415
return new Response(res.data as any)
1516
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { type NextRequest } from 'next/server'
2+
import { NextResponse } from 'next/server'
3+
import { client, getInfo } from '@/app/api/utils/common'
4+
5+
export async function POST(request: NextRequest, { params }: {
6+
params: { conversationId: string }
7+
}) {
8+
const body = await request.json()
9+
const {
10+
auto_generate,
11+
name,
12+
} = body
13+
const { conversationId } = params
14+
const { user } = getInfo(request)
15+
16+
// auto generate name
17+
const { data } = await client.renameConversation(conversationId, name, user, auto_generate)
18+
return NextResponse.json(data)
19+
}

app/api/file-upload/route.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { type NextRequest } from 'next/server'
2+
import { client, getInfo } from '@/app/api/utils/common'
3+
4+
export async function POST(request: NextRequest) {
5+
try {
6+
const formData = await request.formData()
7+
const { user } = getInfo(request)
8+
formData.append('user', user)
9+
const res = await client.fileUpload(formData)
10+
return new Response(res.data.id as any)
11+
}
12+
catch (e: any) {
13+
return new Response(e.message)
14+
}
15+
}

app/api/parameters/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export async function GET(request: NextRequest) {
99
return NextResponse.json(data as object, {
1010
headers: setSession(sessionId),
1111
})
12-
} catch (error) {
13-
return NextResponse.json([]);
12+
}
13+
catch (error) {
14+
return NextResponse.json([])
1415
}
1516
}

app/components/base/app-icon/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from 'classnames'
33
import style from './style.module.css'
44

55
export type AppIconProps = {
6-
size?: 'tiny' | 'small' | 'medium' | 'large'
6+
size?: 'xs' | 'tiny' | 'small' | 'medium' | 'large'
77
rounded?: boolean
88
icon?: string
99
background?: string
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
.appIcon {
22
@apply flex items-center justify-center relative w-9 h-9 text-lg bg-teal-100 rounded-lg grow-0 shrink-0;
33
}
4+
45
.appIcon.large {
56
@apply w-10 h-10;
67
}
8+
79
.appIcon.small {
810
@apply w-8 h-8;
911
}
12+
13+
.appIcon.xs {
14+
@apply w-3 h-3 text-base;
15+
}
16+
1017
.appIcon.tiny {
1118
@apply w-6 h-6 text-base;
1219
}
20+
1321
.appIcon.rounded {
1422
@apply rounded-full;
15-
}
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { forwardRef } from 'react'
2+
import { generate } from './utils'
3+
import type { AbstractNode } from './utils'
4+
5+
export type IconData = {
6+
name: string
7+
icon: AbstractNode
8+
}
9+
10+
export type IconBaseProps = {
11+
data: IconData
12+
className?: string
13+
onClick?: React.MouseEventHandler<SVGElement>
14+
style?: React.CSSProperties
15+
}
16+
17+
const IconBase = forwardRef<React.MutableRefObject<HTMLOrSVGElement>, IconBaseProps>((props, ref) => {
18+
const { data, className, onClick, style, ...restProps } = props
19+
20+
return generate(data.icon, `svg-${data.name}`, {
21+
className,
22+
onClick,
23+
style,
24+
'data-icon': data.name,
25+
'aria-hidden': 'true',
26+
...restProps,
27+
'ref': ref,
28+
})
29+
})
30+
31+
export default IconBase
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"icon": {
3+
"type": "element",
4+
"isRootNode": true,
5+
"name": "svg",
6+
"attributes": {
7+
"width": "12",
8+
"height": "12",
9+
"viewBox": "0 0 12 12",
10+
"fill": "none",
11+
"xmlns": "http://www.w3.org/2000/svg"
12+
},
13+
"children": [
14+
{
15+
"type": "element",
16+
"name": "g",
17+
"attributes": {
18+
"id": "chevron-down"
19+
},
20+
"children": [
21+
{
22+
"type": "element",
23+
"name": "path",
24+
"attributes": {
25+
"id": "Icon",
26+
"d": "M3 4.5L6 7.5L9 4.5",
27+
"stroke": "currentColor",
28+
"stroke-width": "1.5",
29+
"stroke-linecap": "round",
30+
"stroke-linejoin": "round"
31+
},
32+
"children": []
33+
}
34+
]
35+
}
36+
]
37+
},
38+
"name": "ChevronDown"
39+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// GENERATE BY script
2+
// DON NOT EDIT IT MANUALLY
3+
4+
import * as React from 'react'
5+
import data from './data.json'
6+
import IconBase from '@/app/components/base/icons/IconBase'
7+
import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
8+
9+
const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
10+
props,
11+
ref,
12+
) => <IconBase {...props} ref={ref} data={data as IconData} />)
13+
14+
Icon.displayName = 'ChevronDown'
15+
16+
export default Icon
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"icon": {
3+
"type": "element",
4+
"isRootNode": true,
5+
"name": "svg",
6+
"attributes": {
7+
"width": "16",
8+
"height": "16",
9+
"viewBox": "0 0 16 16",
10+
"fill": "none",
11+
"xmlns": "http://www.w3.org/2000/svg"
12+
},
13+
"children": [
14+
{
15+
"type": "element",
16+
"name": "g",
17+
"attributes": {
18+
"id": "image-plus"
19+
},
20+
"children": [
21+
{
22+
"type": "element",
23+
"name": "path",
24+
"attributes": {
25+
"id": "Icon",
26+
"d": "M8.33333 2.00016H5.2C4.0799 2.00016 3.51984 2.00016 3.09202 2.21815C2.71569 2.4099 2.40973 2.71586 2.21799 3.09218C2 3.52001 2 4.08006 2 5.20016V10.8002C2 11.9203 2 12.4803 2.21799 12.9081C2.40973 13.2845 2.71569 13.5904 3.09202 13.7822C3.51984 14.0002 4.07989 14.0002 5.2 14.0002H11.3333C11.9533 14.0002 12.2633 14.0002 12.5176 13.932C13.2078 13.7471 13.7469 13.208 13.9319 12.5178C14 12.2635 14 11.9535 14 11.3335M12.6667 5.3335V1.3335M10.6667 3.3335H14.6667M7 5.66683C7 6.40321 6.40305 7.00016 5.66667 7.00016C4.93029 7.00016 4.33333 6.40321 4.33333 5.66683C4.33333 4.93045 4.93029 4.3335 5.66667 4.3335C6.40305 4.3335 7 4.93045 7 5.66683ZM9.99336 7.94559L4.3541 13.0722C4.03691 13.3605 3.87831 13.5047 3.86429 13.6296C3.85213 13.7379 3.89364 13.8453 3.97546 13.9172C4.06985 14.0002 4.28419 14.0002 4.71286 14.0002H10.9707C11.9301 14.0002 12.4098 14.0002 12.7866 13.839C13.2596 13.6366 13.6365 13.2598 13.8388 12.7868C14 12.41 14 11.9303 14 10.9708C14 10.648 14 10.4866 13.9647 10.3363C13.9204 10.1474 13.8353 9.9704 13.7155 9.81776C13.6202 9.6963 13.4941 9.59546 13.242 9.3938L11.3772 7.90194C11.1249 7.7001 10.9988 7.59919 10.8599 7.56357C10.7374 7.53218 10.6086 7.53624 10.4884 7.57529C10.352 7.61959 10.2324 7.72826 9.99336 7.94559Z",
27+
"stroke": "currentColor",
28+
"stroke-width": "1.25",
29+
"stroke-linecap": "round",
30+
"stroke-linejoin": "round"
31+
},
32+
"children": []
33+
}
34+
]
35+
}
36+
]
37+
},
38+
"name": "ImagePlus"
39+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from 'react'
2+
import data from './data.json'
3+
import IconBase from '@/app/components/base/icons/IconBase'
4+
import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
5+
6+
const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
7+
props,
8+
ref,
9+
) => <IconBase {...props} ref={ref} data={data as IconData} />)
10+
11+
Icon.displayName = 'ImagePlus'
12+
13+
export default Icon
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"icon": {
3+
"type": "element",
4+
"isRootNode": true,
5+
"name": "svg",
6+
"attributes": {
7+
"width": "17",
8+
"height": "16",
9+
"viewBox": "0 0 17 16",
10+
"fill": "none",
11+
"xmlns": "http://www.w3.org/2000/svg"
12+
},
13+
"children": [
14+
{
15+
"type": "element",
16+
"name": "g",
17+
"attributes": {
18+
"id": "link-03"
19+
},
20+
"children": [
21+
{
22+
"type": "element",
23+
"name": "g",
24+
"attributes": {
25+
"id": "Solid"
26+
},
27+
"children": [
28+
{
29+
"type": "element",
30+
"name": "path",
31+
"attributes": {
32+
"fill-rule": "evenodd",
33+
"clip-rule": "evenodd",
34+
"d": "M9.01569 1.83378C9.7701 1.10515 10.7805 0.701975 11.8293 0.711089C12.8781 0.720202 13.8813 1.14088 14.623 1.88251C15.3646 2.62414 15.7853 3.62739 15.7944 4.67618C15.8035 5.72497 15.4003 6.73538 14.6717 7.48979L14.6636 7.49805L12.6637 9.49796C12.2581 9.90362 11.7701 10.2173 11.2327 10.4178C10.6953 10.6183 10.1211 10.7008 9.54897 10.6598C8.97686 10.6189 8.42025 10.4553 7.91689 10.1803C7.41354 9.90531 6.97522 9.52527 6.63165 9.06596C6.41112 8.77113 6.47134 8.35334 6.76618 8.1328C7.06101 7.91226 7.4788 7.97249 7.69934 8.26732C7.92838 8.57353 8.2206 8.82689 8.55617 9.01023C8.89174 9.19356 9.26281 9.30259 9.64422 9.3299C10.0256 9.35722 10.4085 9.30219 10.7667 9.16854C11.125 9.0349 11.4503 8.82576 11.7207 8.55532L13.7164 6.55956C14.1998 6.05705 14.4672 5.38513 14.4611 4.68777C14.455 3.98857 14.1746 3.31974 13.6802 2.82532C13.1857 2.3309 12.5169 2.05045 11.8177 2.04437C11.12 2.03831 10.4478 2.30591 9.94526 2.78967L8.80219 3.92609C8.54108 4.18568 8.11898 4.18445 7.85939 3.92334C7.5998 3.66223 7.60103 3.24012 7.86214 2.98053L9.0088 1.84053L9.01569 1.83378Z",
35+
"fill": "currentColor"
36+
},
37+
"children": []
38+
},
39+
{
40+
"type": "element",
41+
"name": "path",
42+
"attributes": {
43+
"fill-rule": "evenodd",
44+
"clip-rule": "evenodd",
45+
"d": "M5.76493 5.58217C6.30234 5.3817 6.87657 5.29915 7.44869 5.34012C8.0208 5.3811 8.57741 5.54463 9.08077 5.81964C9.58412 6.09465 10.0224 6.47469 10.366 6.93399C10.5865 7.22882 10.5263 7.64662 10.2315 7.86715C9.93665 8.08769 9.51886 8.02746 9.29832 7.73263C9.06928 7.42643 8.77706 7.17307 8.44149 6.98973C8.10592 6.80639 7.73485 6.69737 7.35344 6.67005C6.97203 6.64274 6.58921 6.69777 6.23094 6.83141C5.87266 6.96506 5.54733 7.17419 5.27699 7.44463L3.28123 9.44039C2.79787 9.94291 2.5305 10.6148 2.53656 11.3122C2.54263 12.0114 2.82309 12.6802 3.31751 13.1746C3.81193 13.6691 4.48076 13.9495 5.17995 13.9556C5.87732 13.9616 6.54923 13.6943 7.05174 13.2109L8.18743 12.0752C8.44777 11.8149 8.86988 11.8149 9.13023 12.0752C9.39058 12.3356 9.39058 12.7577 9.13023 13.018L7.99023 14.158L7.98197 14.1662C7.22756 14.8948 6.21715 15.298 5.16837 15.2889C4.11958 15.2798 3.11633 14.8591 2.3747 14.1174C1.63307 13.3758 1.21239 12.3726 1.20328 11.3238C1.19416 10.275 1.59734 9.26458 2.32597 8.51017L2.33409 8.50191L4.33401 6.50199C4.33398 6.50202 4.33404 6.50196 4.33401 6.50199C4.7395 6.09638 5.22756 5.78262 5.76493 5.58217Z",
46+
"fill": "currentColor"
47+
},
48+
"children": []
49+
}
50+
]
51+
}
52+
]
53+
}
54+
]
55+
},
56+
"name": "Link03"
57+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from 'react'
2+
import data from './data.json'
3+
import IconBase from '@/app/components/base/icons/IconBase'
4+
import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
5+
6+
const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
7+
props,
8+
ref,
9+
) => <IconBase {...props} ref={ref} data={data as IconData} />)
10+
11+
Icon.displayName = 'Link03'
12+
13+
export default Icon
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"icon": {
3+
"type": "element",
4+
"isRootNode": true,
5+
"name": "svg",
6+
"attributes": {
7+
"width": "16",
8+
"height": "16",
9+
"viewBox": "0 0 16 16",
10+
"fill": "none",
11+
"xmlns": "http://www.w3.org/2000/svg"
12+
},
13+
"children": [
14+
{
15+
"type": "element",
16+
"name": "g",
17+
"attributes": {
18+
"clip-path": "url(#clip0_6037_51601)"
19+
},
20+
"children": [
21+
{
22+
"type": "element",
23+
"name": "path",
24+
"attributes": {
25+
"d": "M7.99992 1.33398V4.00065M7.99992 12.0007V14.6673M3.99992 8.00065H1.33325M14.6666 8.00065H11.9999M12.7189 12.7196L10.8333 10.834M12.7189 3.33395L10.8333 5.21956M3.28097 12.7196L5.16659 10.834M3.28097 3.33395L5.16659 5.21956",
26+
"stroke": "currentColor",
27+
"stroke-width": "1.25",
28+
"stroke-linecap": "round",
29+
"stroke-linejoin": "round"
30+
},
31+
"children": []
32+
}
33+
]
34+
},
35+
{
36+
"type": "element",
37+
"name": "defs",
38+
"attributes": {},
39+
"children": [
40+
{
41+
"type": "element",
42+
"name": "clipPath",
43+
"attributes": {
44+
"id": "clip0_6037_51601"
45+
},
46+
"children": [
47+
{
48+
"type": "element",
49+
"name": "rect",
50+
"attributes": {
51+
"width": "16",
52+
"height": "16",
53+
"fill": "white"
54+
},
55+
"children": []
56+
}
57+
]
58+
}
59+
]
60+
}
61+
]
62+
},
63+
"name": "Loading02"
64+
}

0 commit comments

Comments
 (0)