diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/develop/page.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/develop/page.tsx
index d544059a84..4101120703 100644
--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/develop/page.tsx
+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/develop/page.tsx
@@ -1,5 +1,4 @@
import React from 'react'
-import { getDictionary } from '@/i18n/server'
import { type Locale } from '@/i18n'
import DevelopMain from '@/app/components/develop'
@@ -8,11 +7,9 @@ export type IDevelopProps = {
}
const Develop = async ({
- params: { locale, appId },
+ params: { appId },
}: IDevelopProps) => {
- const dictionary = await getDictionary(locale)
-
- return
+ return
}
export default Develop
diff --git a/web/app/components/develop/index.tsx b/web/app/components/develop/index.tsx
index a8a16d0ff3..5034a1db7d 100644
--- a/web/app/components/develop/index.tsx
+++ b/web/app/components/develop/index.tsx
@@ -9,20 +9,17 @@ import { fetchAppDetail } from '@/service/apps'
type IDevelopMainProps = {
appId: string
- dictionary: any
}
-const DevelopMain = ({ appId, dictionary }: IDevelopMainProps) => {
+const DevelopMain = ({ appId }: IDevelopMainProps) => {
const commonParams = { url: '/apps', id: appId }
const { data: appDetail } = useSWR(commonParams, fetchAppDetail)
const { t } = useTranslation()
- // const serverApi = `${appDetail?.site?.app_base_url}/api/${appDetail?.site?.access_token}`
-
return (
-
{dictionary.app?.develop?.title}
+
diff --git a/web/app/components/i18n-server.tsx b/web/app/components/i18n-server.tsx
index 39a5f7ca1d..25e999ed48 100644
--- a/web/app/components/i18n-server.tsx
+++ b/web/app/components/i18n-server.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import I18N from './i18n'
import { ToastProvider } from './base/toast'
-import { getDictionary, getLocaleOnServer } from '@/i18n/server'
+import { getLocaleOnServer } from '@/i18n/server'
export type II18NServerProps = {
children: React.ReactNode
@@ -11,10 +11,9 @@ const I18NServer = async ({
children,
}: II18NServerProps) => {
const locale = getLocaleOnServer()
- const dictionary = await getDictionary(locale)
return (
-
+
{children}
)
diff --git a/web/app/components/i18n.tsx b/web/app/components/i18n.tsx
index 32e1c93073..4166449e76 100644
--- a/web/app/components/i18n.tsx
+++ b/web/app/components/i18n.tsx
@@ -9,12 +9,10 @@ import { setLocaleOnClient } from '@/i18n/client'
export type II18nProps = {
locale: Locale
- dictionary: Record
children: React.ReactNode
}
const I18n: FC = ({
locale,
- dictionary,
children,
}) => {
useEffect(() => {
@@ -24,7 +22,7 @@ const I18n: FC = ({
return (
{children}
diff --git a/web/app/components/share/text-generation/history/index.tsx b/web/app/components/share/text-generation/history/index.tsx
deleted file mode 100644
index a100c98a17..0000000000
--- a/web/app/components/share/text-generation/history/index.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-'use client'
-import React, { useState } from 'react'
-import useSWR from 'swr'
-import {
- ChevronDownIcon,
- ChevronUpIcon,
-} from '@heroicons/react/24/outline'
-import { fetchHistories } from '@/models/history'
-import type { History as HistoryItem } from '@/models/history'
-import Loading from '@/app/components/base/loading'
-import { mockAPI } from '@/test/test_util'
-
-mockAPI()
-
-export type IHistoryProps = {
- dictionary: any
-}
-
-const HistoryCard = (
- { history }: { history: HistoryItem },
-) => {
- return (
-
-
- {history.source}
-
-
-
- {history.target}
-
-
- )
-}
-
-const History = ({
- dictionary,
-}: IHistoryProps) => {
- const { data, error } = useSWR('http://localhost:3000/api/histories', fetchHistories)
- const [showHistory, setShowHistory] = useState(false)
-
- const DivideLine = () => {
- return
- {/* divider line */}
-
-
- {!showHistory ?
:
}
-
{dictionary.app.textGeneration.history}
- {!showHistory ?
:
}
-
-
- }
-
- if (error)
- return failed to load
- if (!data)
- return
- return showHistory
- ? setShowHistory(v => !v)
- }>
-
-
- {data.histories.map((item: HistoryItem) =>
- )}
-
-
- : setShowHistory(true)
- }>
-
-
-}
-export default History
diff --git a/web/dictionaries/en.json b/web/dictionaries/en.json
deleted file mode 100644
index 2ec65fce67..0000000000
--- a/web/dictionaries/en.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "common": {
- "confrim": "Confirm",
- "cancel": "Cancel",
- "refresh": "Refresh"
- },
- "index": {
- "welcome": "Welcome to "
- },
- "signin": {},
- "app": {
- "overview": {
- "title": "Overview",
- "To get started,": "To get started,",
- "enter your OpenAI API key below": "enter your OpenAI API key below",
- "Get your API key from OpenAI dashboard": "Get your API key from OpenAI dashboard",
- "Token Usage": "Token Usage"
- },
- "logs": {
- "title": "Logs",
- "description": "You can review and annotate the conversation and response text of the LLM, which will be used for subsequent model fine-tuning."
- },
- "textGeneration": {
- "history": "History"
- }
- }
-}
\ No newline at end of file
diff --git a/web/dictionaries/zh-Hans.json b/web/dictionaries/zh-Hans.json
deleted file mode 100644
index e88b03b733..0000000000
--- a/web/dictionaries/zh-Hans.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "common": {
- "confrim": "确定",
- "cancel": "取消",
- "refresh": "刷新"
- },
- "index": {
- "welcome": "欢迎来到 "
- },
- "signin": {},
- "app": {
- "overview": {
- "title": "概览",
- "To get started,": "从这里开始",
- "enter your OpenAI API key below 👇": "输入你的 OpenAI API 密钥👇",
- "Get your API key from OpenAI dashboard": "去 OpenAI 管理面板获取",
- "Token Usage": "Token 消耗"
- },
- "logs": {
- "title": "日志",
- "description": "日志记录了应用的运行情况,包括用户的输入和 AI 的回复。"
- },
- "textGeneration": {
- "history": "历史"
- }
- }
-}
\ No newline at end of file
diff --git a/web/i18n/server.ts b/web/i18n/server.ts
index ac9630dd49..5b97004bb0 100644
--- a/web/i18n/server.ts
+++ b/web/i18n/server.ts
@@ -27,17 +27,3 @@ export const getLocaleOnServer = (): Locale => {
const matchedLocale = match(languages, locales, i18n.defaultLocale) as Locale
return matchedLocale
}
-
-// We enumerate all dictionaries here for better linting and typescript support
-// We also get the default import for cleaner types
-const dictionaries = {
- 'en': () => import('@/dictionaries/en.json').then(module => module.default),
- 'zh-Hans': () => import('@/dictionaries/zh-Hans.json').then(module => module.default),
-} as { [locale: string]: () => Promise }
-
-export const getDictionary = async (locale: Locale = 'en') => {
- try {
- return await dictionaries[locale]()
- }
- catch (e) { console.error('locale not found', locale) }
-}
diff --git a/web/middleware.ts b/web/middleware.ts
deleted file mode 100644
index 7d616d0f93..0000000000
--- a/web/middleware.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { match } from '@formatjs/intl-localematcher'
-import Negotiator from 'negotiator'
-import { NextResponse } from 'next/server'
-import type { NextRequest } from 'next/server'
-import type { Locale } from './i18n'
-import { i18n } from './i18n'
-
-export const getLocale = (request: NextRequest): Locale => {
- // @ts-expect-error locales are readonly
- const locales: Locale[] = i18n.locales
-
- let languages: string[] | undefined
- // get locale from cookie
- const localeCookie = request.cookies.get('locale')
- languages = localeCookie?.value ? [localeCookie.value] : []
-
- if (!languages.length) {
- // Negotiator expects plain object so we need to transform headers
- const negotiatorHeaders: Record = {}
- request.headers.forEach((value, key) => (negotiatorHeaders[key] = value))
- // Use negotiator and intl-localematcher to get best locale
- languages = new Negotiator({ headers: negotiatorHeaders }).languages()
- }
-
- // match locale
- let matchedLocale: Locale = i18n.defaultLocale
- try {
- // If languages is ['*'], Error would happen in match function.
- matchedLocale = match(languages, locales, i18n.defaultLocale) as Locale
- }
- catch (e) {}
- return matchedLocale
-}
-
-export const middleware = async (request: NextRequest) => {
- const pathname = request.nextUrl.pathname
- if (/\.(css|js(on)?|ico|svg|png)$/.test(pathname))
- return
-
- const locale = getLocale(request)
- const response = NextResponse.next()
- response.cookies.set('locale', locale)
- return response
-}
diff --git a/web/models/history.ts b/web/models/history.ts
deleted file mode 100644
index 90d6245cb9..0000000000
--- a/web/models/history.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export type History = {
- id: string
- source: string
- target: string
-}
-export type HistoryResponse = {
- histories: History[]
-}
-
-export const fetchHistories = (url: string) =>
- fetch(url).then(r => r.json())
diff --git a/web/test/factories/index.ts b/web/test/factories/index.ts
index b36719fa75..07da804e84 100644
--- a/web/test/factories/index.ts
+++ b/web/test/factories/index.ts
@@ -1,20 +1,7 @@
import { Factory } from 'miragejs'
import { faker } from '@faker-js/faker'
-import type { History } from '@/models/history'
import type { User } from '@/models/user'
-import type { Log } from '@/models/log'
-
-export const seedHistory = () => {
- return Factory.extend>({
- source() {
- return faker.address.streetAddress()
- },
- target() {
- return faker.address.streetAddress()
- },
- })
-}
export const seedUser = () => {
return Factory.extend>({
@@ -41,26 +28,3 @@ export const seedUser = () => {
},
})
}
-
-export const seedLog = () => {
- return Factory.extend>({
- get key() {
- return faker.datatype.uuid()
- },
- get conversationId() {
- return faker.datatype.uuid()
- },
- get question() {
- return faker.lorem.sentence()
- },
- get answer() {
- return faker.lorem.sentence()
- },
- get userRate() {
- return faker.datatype.number(5)
- },
- get adminRate() {
- return faker.datatype.number(5)
- },
- })
-}
diff --git a/web/test/test_util.ts b/web/test/test_util.ts
deleted file mode 100644
index 6495919cea..0000000000
--- a/web/test/test_util.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { Model, createServer } from 'miragejs'
-import type { User } from '@/models/user'
-import type { History } from '@/models/history'
-import type { Log } from '@/models/log'
-import { seedHistory, seedLog, seedUser } from '@/test/factories'
-
-export function mockAPI() {
- if (process.env.NODE_ENV === 'development') {
- console.log('in development mode, starting mock server ... ')
- const server = createServer({
- environment: process.env.NODE_ENV,
- factories: {
- user: seedUser(),
- history: seedHistory(),
- log: seedLog(),
- },
- models: {
- user: Model.extend>({}),
- history: Model.extend>({}),
- log: Model.extend>({}),
- },
- routes() {
- this.namespace = '/api'
- this.get('/users', () => {
- return this.schema.all('user')
- })
- this.get('/histories', () => {
- return this.schema.all('history')
- })
- this.get('/logs', () => {
- return this.schema.all('log')
- })
- },
- seeds(server) {
- server.createList('user', 20)
- server.createList('history', 50)
- server.createList('log', 50)
- },
- })
- return server
- }
- console.log('Not in development mode, not starting mock server ... ')
- return null
-}