Skip to content

Commit

Permalink
chore: Enable Japanese descriptions for Tools (#8646)
Browse files Browse the repository at this point in the history
  • Loading branch information
totsukash authored Sep 23, 2024
1 parent cae73b9 commit 03fdf5e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion api/core/tools/entities/common_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class I18nObject(BaseModel):

zh_Hans: Optional[str] = None
pt_BR: Optional[str] = None
ja_JP: Optional[str] = None
en_US: str

def __init__(self, **data):
Expand All @@ -18,6 +19,8 @@ def __init__(self, **data):
self.zh_Hans = self.en_US
if not self.pt_BR:
self.pt_BR = self.en_US
if not self.ja_JP:
self.ja_JP = self.en_US

def to_dict(self) -> dict:
return {"zh_Hans": self.zh_Hans, "en_US": self.en_US, "pt_BR": self.pt_BR}
return {"zh_Hans": self.zh_Hans, "en_US": self.en_US, "pt_BR": self.pt_BR, "ja_JP": self.ja_JP}
2 changes: 2 additions & 0 deletions api/core/tools/provider/builtin/arxiv/arxiv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ identity:
label:
en_US: ArXiv
zh_Hans: ArXiv
ja_JP: ArXiv
description:
en_US: Access to a vast repository of scientific papers and articles in various fields of research.
zh_Hans: 访问各个研究领域大量科学论文和文章的存储库。
ja_JP: 多様な研究分野の科学論文や記事の膨大なリポジトリへのアクセス。
icon: icon.svg
tags:
- search
4 changes: 4 additions & 0 deletions api/core/tools/provider/builtin/arxiv/tools/arxiv_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ identity:
label:
en_US: Arxiv Search
zh_Hans: Arxiv 搜索
ja_JP: Arxiv 検索
description:
human:
en_US: A tool for searching scientific papers and articles from the Arxiv repository. Input can be an Arxiv ID or an author's name.
zh_Hans: 一个用于从Arxiv存储库搜索科学论文和文章的工具。 输入可以是Arxiv ID或作者姓名。
ja_JP: Arxivリポジトリから科学論文や記事を検索するためのツールです。入力はArxiv IDまたは著者名にすることができます。
llm: A tool for searching scientific papers and articles from the Arxiv repository. Input can be an Arxiv ID or an author's name.
parameters:
- name: query
Expand All @@ -16,8 +18,10 @@ parameters:
label:
en_US: Query string
zh_Hans: 查询字符串
ja_JP: クエリ文字列
human_description:
en_US: The Arxiv ID or author's name used for searching.
zh_Hans: 用于搜索的Arxiv ID或作者姓名。
ja_JP: 検索に使用されるArxiv IDまたは著者名。
llm_description: The Arxiv ID or author's name used for searching.
form: llm
2 changes: 2 additions & 0 deletions api/services/tools/tools_transform_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ def builtin_provider_to_user_provider(
en_US=provider_controller.identity.description.en_US,
zh_Hans=provider_controller.identity.description.zh_Hans,
pt_BR=provider_controller.identity.description.pt_BR,
ja_JP=provider_controller.identity.description.ja_JP,
),
icon=provider_controller.identity.icon,
label=I18nObject(
en_US=provider_controller.identity.label.en_US,
zh_Hans=provider_controller.identity.label.zh_Hans,
pt_BR=provider_controller.identity.label.pt_BR,
ja_JP=provider_controller.identity.label.ja_JP,
),
type=ToolProviderType.BUILT_IN,
masked_credentials={},
Expand Down
6 changes: 2 additions & 4 deletions web/i18n/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ export const languages = data.languages
export const LanguagesSupported = languages.filter(item => item.supported).map(item => item.value)

export const getLanguage = (locale: string) => {
if (locale === 'zh-Hans')
return locale.replace('-', '_')

return LanguagesSupported[0].replace('-', '_')
const supportedLocale = LanguagesSupported.find(lang => lang.startsWith(locale.split('-')[0]))
return (supportedLocale || LanguagesSupported[0]).replace('-', '_')
}

export const NOTICE_I18N = {
Expand Down

0 comments on commit 03fdf5e

Please sign in to comment.