Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/apps/chat/models/chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def guess_sys_question(self, articles_number: int = 4):
sqlbot_name=self.sqlbot_name)

def guess_user_question(self, old_questions: str = "[]"):
return get_guess_question_template()['user'].format(question=self.question, schema=self.db_schema,
return get_guess_question_template()['user'].format(lang=self.lang, question=self.question, schema=self.db_schema,
old_questions=old_questions)

def filter_sys_question(self):
Expand Down Expand Up @@ -411,7 +411,7 @@ class ChatQuestionBase(BaseModel):
class McpQuestion(ChatQuestionBase):
token: str = Body(description='token')
stream: Optional[bool] = Body(description='是否流式输出,默认为true开启, 关闭false则返回JSON对象', default=True)
lang: Optional[str] = Body(description='语言:zh-CN|zh-TW|en|ko-KR', default='zh-CN')
lang: Optional[str] = Body(description='语言:zh-CN|zh-TW|en|ko-KR|th-TH', default='zh-CN')
datasource_id: Optional[int | str] = Body(description='数据源ID,仅当当前对话没有确定数据源时有效', default=None)
return_img: Optional[bool] = Body(description='是否返回图表,默认为true开启, 关闭false则仅返回数据', default=True)
custom_model: Optional[str | int] = Body(description='模型ID', default=None)
Expand Down
2 changes: 2 additions & 0 deletions backend/apps/chat/task/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,8 @@ def get_lang_name(lang: str):
return '英文'
if normalized.startswith('ko'):
return '韩语'
if normalized.startswith('th'):
return '泰语'
return '简体中文'


Expand Down
2 changes: 1 addition & 1 deletion backend/apps/mcp/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def get_model_by_ws(session: SessionDep, mcp_oid: WsMcp):
async def mcp_question(session: SessionDep, trans: Trans, chat: McpQuestion):
session_user = get_user(session, chat.token)
lang = chat.lang
if lang in ["zh-CN", "zh-TW", "en", "ko-KR"]:
if lang in ["zh-CN", "zh-TW", "en", "ko-KR", "th-TH"]:
session_user.language = lang
# if chat.oid:
# w_list = await user_ws_options(session, session_user.id, trans)
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/system/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ async def batch_del(session: SessionDep, id_list: list[int]):
@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="current_user.id")
async def langChange(session: SessionDep, current_user: CurrentUser, trans: Trans, language: UserLanguage):
lang = language.language
if lang not in ["zh-CN", "zh-TW", "en", "ko-KR"]:
if lang not in ["zh-CN", "zh-TW", "en", "ko-KR", "th-TH"]:
raise Exception(trans('i18n_user.language_not_support', key = lang))
db_user: UserModel = get_db_user(session=session, user_id=current_user.id)
db_user.language = lang
Expand Down
6 changes: 3 additions & 3 deletions backend/apps/system/schemas/system_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BaseUser(BaseModel):


class BaseUserDTO(BaseUser, BaseCreatorDTO):
language: str = Field(pattern=r"^(zh-CN|zh-TW|en|ko-KR)$", default="zh-CN", description="用户语言")
language: str = Field(pattern=r"^(zh-CN|zh-TW|en|ko-KR|th-TH)$", default="zh-CN", description="用户语言")
password: str
status: int = 1
origin: int = 0
Expand All @@ -47,8 +47,8 @@ def to_dict(self):

@field_validator("language")
def validate_language(cls, lang: str) -> str:
if not re.fullmatch(r"^(zh-CN|zh-TW|en|ko-KR)$", lang):
raise ValueError("Language must be 'zh-CN', 'zh-TW', 'en', or 'ko-KR'")
if not re.fullmatch(r"^(zh-CN|zh-TW|en|ko-KR|th-TH)$", lang):
raise ValueError("Language must be 'zh-CN', 'zh-TW', 'en', 'ko-KR', or 'th-TH'")
return lang


Expand Down
209 changes: 209 additions & 0 deletions backend/locales/th-TH.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions backend/templates/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,6 @@ template:

guess:
system: |
### 请使用语言:{lang} 回答,不需要输出深度思考过程

### 说明:
您的任务是根据给定的表结构,用户问题以及以往用户提问,推测用户接下来可能提问的1-{articles_number}个问题。
请遵循以下规则:
Expand All @@ -581,7 +579,6 @@ template:
- 最多返回{articles_number}个你推测出的结果
- 若无法推测,则返回空数据JSON:
[]
- 若你的给出的JSON不是{lang}的,则必须翻译为{lang}

### 响应, 请直接返回JSON结果(不要包含任何其他文本):

Expand All @@ -595,7 +592,8 @@ template:
### 以往提问:
{old_questions}

/no_think
## 请根据上述要求,使用语言:{lang} 进行输出,不需要输出深度思考过程
## JSON列表内的值,语言请与 {lang} 保持一致
analysis:
system: |
<Instruction>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Language-selector/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const languageOptions = computed(() => [
{ value: 'zh-CN', label: t('common.simplified_chinese') },
{ value: 'zh-TW', label: t('common.traditional_chinese') },
{ value: 'ko-KR', label: t('common.korean') },
{ value: 'th-TH', label: t('common.thai') },
])

const selectedLanguage = computed(() => {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/layout/Person.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ const languageList = computed(() => [
name: '한국인',
value: 'ko-KR',
},
{
name: 'ไทย',
value: 'th-TH',
},
])
const popoverRef = ref()

Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"reset": "Reset",
"simplified_chinese": "简体中文",
"korean": "한국어",
"thai": "ไทย",
"traditional_chinese": "繁體中文",
"help": "Help",
"language": "Language",
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import en from './en.json'
import zhCN from './zh-CN.json'
import zhTw from './zh-TW.json'
import koKR from './ko-KR.json'
import thTH from './th-TH.json'
import elementEnLocale from 'element-plus-secondary/es/locale/lang/en'
import elementZhLocale from 'element-plus-secondary/es/locale/lang/zh-cn'
import elementTwLocale from 'element-plus-secondary/es/locale/lang/zh-tw'
import elementThLocale from 'element-plus-secondary/es/locale/lang/th'
import { useCache } from '@/utils/useCache'
import { getBrowserLocale } from '@/utils/utils'

Expand Down Expand Up @@ -57,6 +59,10 @@ const messages = {
...koKR,
el: elementKoLocale,
},
'th-TH': {
...thTH,
el: elementThLocale,
},
}

export const i18n = createI18n({
Expand All @@ -72,6 +78,7 @@ const elementLocales = {
'zh-CN': elementZhLocale,
'zh-TW': elementTwLocale,
'ko-KR': elementKoLocale,
'th-TH': elementThLocale,
} as const

export const getElementLocale = () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"reset": "재설정",
"simplified_chinese": "简体中文",
"korean": "한국어",
"thai": "ไทย",
"traditional_chinese": "繁體中文",
"help": "도움말",
"language": "언어",
Expand Down
Loading
Loading