From 57024614bd4e8d30896202e8315c83d597e8267a Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:00:34 +0800 Subject: [PATCH] fix: Fix typo in credentials field name (#2155) --- api/core/tools/docs/en_US/tool_scale_out.md | 2 +- api/core/tools/docs/zh_Hans/tool_scale_out.md | 2 +- api/core/tools/entities/user_entities.py | 2 +- .../tools/provider/builtin/chart/chart.yaml | 2 +- .../tools/provider/builtin/dalle/dalle.yaml | 2 +- .../tools/provider/builtin/google/google.yaml | 2 +- .../stablediffusion/stablediffusion.yaml | 2 +- .../tools/provider/builtin/time/time.yaml | 2 +- .../builtin/vectorizer/vectorizer.yaml | 2 +- .../builtin/webscraper/webscraper.yaml | 2 +- .../provider/builtin/wikipedia/wikipedia.yaml | 2 +- .../builtin/wolframalpha/wolframalpha.yaml | 2 +- .../tools/provider/builtin/yahoo/yahoo.yaml | 2 +- .../provider/builtin/youtube/youtube.yaml | 2 +- .../tools/provider/builtin_tool_provider.py | 14 +++++----- api/core/tools/provider/tool_provider.py | 6 ++--- api/core/tools/tool/api_tool.py | 2 +- api/core/tools/tool/dataset_retriever_tool.py | 2 +- api/core/tools/tool/tool.py | 4 +-- api/core/tools/tool_manager.py | 26 +++++++++---------- api/core/tools/utils/configration.py | 14 +++++----- ...6f3c800_rename_api_provider_credentails.py | 2 +- api/services/tools_manage_service.py | 4 +-- 23 files changed, 51 insertions(+), 51 deletions(-) diff --git a/api/core/tools/docs/en_US/tool_scale_out.md b/api/core/tools/docs/en_US/tool_scale_out.md index 90aa38bfdd..f791942397 100644 --- a/api/core/tools/docs/en_US/tool_scale_out.md +++ b/api/core/tools/docs/en_US/tool_scale_out.md @@ -45,7 +45,7 @@ identity: en_US: Google zh_Hans: Google icon: icon.svg -credentails_for_provider: # Credential field +credentials_for_provider: # Credential field serpapi_api_key: # Credential field name type: secret-input # Credential field type required: true # Required or not diff --git a/api/core/tools/docs/zh_Hans/tool_scale_out.md b/api/core/tools/docs/zh_Hans/tool_scale_out.md index 08746c70fc..034e24e784 100644 --- a/api/core/tools/docs/zh_Hans/tool_scale_out.md +++ b/api/core/tools/docs/zh_Hans/tool_scale_out.md @@ -45,7 +45,7 @@ identity: en_US: Google zh_Hans: Google icon: icon.svg -credentails_for_provider: # 凭据字段 +credentials_for_provider: # 凭据字段 serpapi_api_key: # 凭据字段名称 type: secret-input # 凭据字段类型 required: true # 是否必填 diff --git a/api/core/tools/entities/user_entities.py b/api/core/tools/entities/user_entities.py index ce4723f071..305b6668b5 100644 --- a/api/core/tools/entities/user_entities.py +++ b/api/core/tools/entities/user_entities.py @@ -38,7 +38,7 @@ class UserToolProvider(BaseModel): } class UserToolProviderCredentials(BaseModel): - credentails: Dict[str, ToolProviderCredentials] + credentials: Dict[str, ToolProviderCredentials] class UserTool(BaseModel): author: str diff --git a/api/core/tools/provider/builtin/chart/chart.yaml b/api/core/tools/provider/builtin/chart/chart.yaml index 70aa2f388f..7aac32b3bb 100644 --- a/api/core/tools/provider/builtin/chart/chart.yaml +++ b/api/core/tools/provider/builtin/chart/chart.yaml @@ -10,4 +10,4 @@ identity: zh_Hans: 图表生成是一个用于生成可视化图表的工具,你可以通过它来生成柱状图、折线图、饼图等各类图表 pt_BR: O Gerador de gráficos é uma ferramenta para gerar gráficos estatísticos como gráfico de barras, gráfico de linhas, gráfico de pizza, etc. icon: icon.png -credentails_for_provider: +credentials_for_provider: diff --git a/api/core/tools/provider/builtin/dalle/dalle.yaml b/api/core/tools/provider/builtin/dalle/dalle.yaml index b347915e80..a99401d82d 100644 --- a/api/core/tools/provider/builtin/dalle/dalle.yaml +++ b/api/core/tools/provider/builtin/dalle/dalle.yaml @@ -10,7 +10,7 @@ identity: zh_Hans: DALL-E 绘画 pt_BR: DALL-E art icon: icon.png -credentails_for_provider: +credentials_for_provider: openai_api_key: type: secret-input required: true diff --git a/api/core/tools/provider/builtin/google/google.yaml b/api/core/tools/provider/builtin/google/google.yaml index 793aed3936..43b75b51cd 100644 --- a/api/core/tools/provider/builtin/google/google.yaml +++ b/api/core/tools/provider/builtin/google/google.yaml @@ -10,7 +10,7 @@ identity: zh_Hans: GoogleSearch pt_BR: Google icon: icon.svg -credentails_for_provider: +credentials_for_provider: serpapi_api_key: type: secret-input required: true diff --git a/api/core/tools/provider/builtin/stablediffusion/stablediffusion.yaml b/api/core/tools/provider/builtin/stablediffusion/stablediffusion.yaml index 9ceaf1ba76..7b918cb854 100644 --- a/api/core/tools/provider/builtin/stablediffusion/stablediffusion.yaml +++ b/api/core/tools/provider/builtin/stablediffusion/stablediffusion.yaml @@ -10,7 +10,7 @@ identity: zh_Hans: Stable Diffusion 是一个可以在本地部署的图片生成的工具。 pt_BR: Stable Diffusion is a tool for generating images which can be deployed locally. icon: icon.png -credentails_for_provider: +credentials_for_provider: base_url: type: secret-input required: true diff --git a/api/core/tools/provider/builtin/time/time.yaml b/api/core/tools/provider/builtin/time/time.yaml index 2332011425..8ea67cded5 100644 --- a/api/core/tools/provider/builtin/time/time.yaml +++ b/api/core/tools/provider/builtin/time/time.yaml @@ -10,4 +10,4 @@ identity: zh_Hans: 一个用于获取当前时间的工具。 pt_BR: A tool for getting the current time. icon: icon.svg -credentails_for_provider: +credentials_for_provider: diff --git a/api/core/tools/provider/builtin/vectorizer/vectorizer.yaml b/api/core/tools/provider/builtin/vectorizer/vectorizer.yaml index 4798544aee..07a20380e9 100644 --- a/api/core/tools/provider/builtin/vectorizer/vectorizer.yaml +++ b/api/core/tools/provider/builtin/vectorizer/vectorizer.yaml @@ -10,7 +10,7 @@ identity: zh_Hans: 一个将 PNG 和 JPG 图像快速轻松地转换为 SVG 矢量图的工具。 pt_BR: Convert your PNG and JPG images to SVG vectors quickly and easily. Fully automatically. Using AI. icon: icon.png -credentails_for_provider: +credentials_for_provider: api_key_name: type: secret-input required: true diff --git a/api/core/tools/provider/builtin/webscraper/webscraper.yaml b/api/core/tools/provider/builtin/webscraper/webscraper.yaml index 40683ff391..056108f036 100644 --- a/api/core/tools/provider/builtin/webscraper/webscraper.yaml +++ b/api/core/tools/provider/builtin/webscraper/webscraper.yaml @@ -10,4 +10,4 @@ identity: zh_Hans: 一个用于抓取网页的工具。 pt_BR: Web Scrapper tool kit is used to scrape web icon: icon.svg -credentails_for_provider: +credentials_for_provider: diff --git a/api/core/tools/provider/builtin/wikipedia/wikipedia.yaml b/api/core/tools/provider/builtin/wikipedia/wikipedia.yaml index c9dbc41298..f4b5da8947 100644 --- a/api/core/tools/provider/builtin/wikipedia/wikipedia.yaml +++ b/api/core/tools/provider/builtin/wikipedia/wikipedia.yaml @@ -10,4 +10,4 @@ identity: zh_Hans: 维基百科是一个由全世界的志愿者创建和编辑的免费在线百科全书。 pt_BR: Wikipedia is a free online encyclopedia, created and edited by volunteers around the world. icon: icon.svg -credentails_for_provider: +credentials_for_provider: diff --git a/api/core/tools/provider/builtin/wolframalpha/wolframalpha.yaml b/api/core/tools/provider/builtin/wolframalpha/wolframalpha.yaml index 8b1c9a755b..e4cc465712 100644 --- a/api/core/tools/provider/builtin/wolframalpha/wolframalpha.yaml +++ b/api/core/tools/provider/builtin/wolframalpha/wolframalpha.yaml @@ -10,7 +10,7 @@ identity: zh_Hans: WolframAlpha 是一个强大的计算知识引擎。 pt_BR: WolframAlpha is a powerful computational knowledge engine. icon: icon.svg -credentails_for_provider: +credentials_for_provider: appid: type: secret-input required: true diff --git a/api/core/tools/provider/builtin/yahoo/yahoo.yaml b/api/core/tools/provider/builtin/yahoo/yahoo.yaml index 6632aedc2f..b16517eaf9 100644 --- a/api/core/tools/provider/builtin/yahoo/yahoo.yaml +++ b/api/core/tools/provider/builtin/yahoo/yahoo.yaml @@ -10,4 +10,4 @@ identity: zh_Hans: 雅虎财经,获取并整理出最新的新闻、股票报价等一切你想要的财经信息。 pt_BR: Finance, and Yahoo! get the latest news, stock quotes, and interactive chart with Yahoo! icon: icon.png -credentails_for_provider: +credentials_for_provider: diff --git a/api/core/tools/provider/builtin/youtube/youtube.yaml b/api/core/tools/provider/builtin/youtube/youtube.yaml index 2bc35e9d77..0fa267b2a9 100644 --- a/api/core/tools/provider/builtin/youtube/youtube.yaml +++ b/api/core/tools/provider/builtin/youtube/youtube.yaml @@ -10,7 +10,7 @@ identity: zh_Hans: Youtube(油管)是全球最大的视频分享网站,用户可以在上面上传、观看和分享视频。 pt_BR: Youtube é o maior site de compartilhamento de vídeos do mundo, onde os usuários podem fazer upload, assistir e compartilhar vídeos. icon: icon.png -credentails_for_provider: +credentials_for_provider: google_api_key: type: secret-input required: true diff --git a/api/core/tools/provider/builtin_tool_provider.py b/api/core/tools/provider/builtin_tool_provider.py index e071dcbea0..721a8ebea5 100644 --- a/api/core/tools/provider/builtin_tool_provider.py +++ b/api/core/tools/provider/builtin_tool_provider.py @@ -30,14 +30,14 @@ class BuiltinToolProviderController(ToolProviderController): except: raise ToolProviderNotFoundError(f'can not load provider yaml for {provider}') - if 'credentails_for_provider' in provider_yaml and provider_yaml['credentails_for_provider'] is not None: + if 'credentials_for_provider' in provider_yaml and provider_yaml['credentials_for_provider'] is not None: # set credentials name - for credential_name in provider_yaml['credentails_for_provider']: - provider_yaml['credentails_for_provider'][credential_name]['name'] = credential_name + for credential_name in provider_yaml['credentials_for_provider']: + provider_yaml['credentials_for_provider'][credential_name]['name'] = credential_name super().__init__(**{ 'identity': provider_yaml['identity'], - 'credentials_schema': provider_yaml['credentails_for_provider'] if 'credentails_for_provider' in provider_yaml else None, + 'credentials_schema': provider_yaml['credentials_for_provider'] if 'credentials_for_provider' in provider_yaml else None, }) def _get_bulitin_tools(self) -> List[Tool]: @@ -75,7 +75,7 @@ class BuiltinToolProviderController(ToolProviderController): self.tools = tools return tools - def get_credentails_schema(self) -> Dict[str, ToolProviderCredentials]: + def get_credentials_schema(self) -> Dict[str, ToolProviderCredentials]: """ returns the credentials schema of the provider @@ -86,14 +86,14 @@ class BuiltinToolProviderController(ToolProviderController): return self.credentials_schema.copy() - def user_get_credentails_schema(self) -> UserToolProviderCredentials: + def user_get_credentials_schema(self) -> UserToolProviderCredentials: """ returns the credentials schema of the provider, this method is used for user :return: the credentials schema """ credentials = self.credentials_schema.copy() - return UserToolProviderCredentials(credentails=credentials) + return UserToolProviderCredentials(credentials=credentials) def get_tools(self) -> List[Tool]: """ diff --git a/api/core/tools/provider/tool_provider.py b/api/core/tools/provider/tool_provider.py index 722b1662a8..aa3f666124 100644 --- a/api/core/tools/provider/tool_provider.py +++ b/api/core/tools/provider/tool_provider.py @@ -15,7 +15,7 @@ class ToolProviderController(BaseModel, ABC): tools: Optional[List[Tool]] = None credentials_schema: Optional[Dict[str, ToolProviderCredentials]] = None - def get_credentails_schema(self) -> Dict[str, ToolProviderCredentials]: + def get_credentials_schema(self) -> Dict[str, ToolProviderCredentials]: """ returns the credentials schema of the provider @@ -23,14 +23,14 @@ class ToolProviderController(BaseModel, ABC): """ return self.credentials_schema.copy() - def user_get_credentails_schema(self) -> UserToolProviderCredentials: + def user_get_credentials_schema(self) -> UserToolProviderCredentials: """ returns the credentials schema of the provider, this method is used for user :return: the credentials schema """ credentials = self.credentials_schema.copy() - return UserToolProviderCredentials(credentails=credentials) + return UserToolProviderCredentials(credentials=credentials) @abstractmethod def get_tools(self) -> List[Tool]: diff --git a/api/core/tools/tool/api_tool.py b/api/core/tools/tool/api_tool.py index 896adc5b81..4328c7d1e9 100644 --- a/api/core/tools/tool/api_tool.py +++ b/api/core/tools/tool/api_tool.py @@ -30,7 +30,7 @@ class ApiTool(Tool): runtime=Tool.Runtime(**meta) ) - def validate_credentials(self, credentails: Dict[str, Any], parameters: Dict[str, Any], format_only: bool = False) -> None: + def validate_credentials(self, credentials: Dict[str, Any], parameters: Dict[str, Any], format_only: bool = False) -> None: """ validate the credentials for Api tool """ diff --git a/api/core/tools/tool/dataset_retriever_tool.py b/api/core/tools/tool/dataset_retriever_tool.py index 800952226a..bcf0aa2935 100644 --- a/api/core/tools/tool/dataset_retriever_tool.py +++ b/api/core/tools/tool/dataset_retriever_tool.py @@ -88,7 +88,7 @@ class DatasetRetrieverTool(Tool): return self.create_text_message(text=result) - def validate_credentials(self, credentails: Dict[str, Any], parameters: Dict[str, Any]) -> None: + def validate_credentials(self, credentials: Dict[str, Any], parameters: Dict[str, Any]) -> None: """ validate the credentials for dataset retriever tool """ diff --git a/api/core/tools/tool/tool.py b/api/core/tools/tool/tool.py index 4e29b427a9..cce6ffcc72 100644 --- a/api/core/tools/tool/tool.py +++ b/api/core/tools/tool/tool.py @@ -228,11 +228,11 @@ class Tool(BaseModel, ABC): def _invoke(self, user_id: str, tool_paramters: Dict[str, Any]) -> Union[ToolInvokeMessage, List[ToolInvokeMessage]]: pass - def validate_credentials(self, credentails: Dict[str, Any], parameters: Dict[str, Any]) -> None: + def validate_credentials(self, credentials: Dict[str, Any], parameters: Dict[str, Any]) -> None: """ validate the credentials - :param credentails: the credentials + :param credentials: the credentials :param parameters: the parameters """ pass diff --git a/api/core/tools/tool_manager.py b/api/core/tools/tool_manager.py index 4b88d9b9e8..0dbb1c1116 100644 --- a/api/core/tools/tool_manager.py +++ b/api/core/tools/tool_manager.py @@ -175,11 +175,11 @@ class ToolManager: controller = ToolManager.get_builtin_provider(provider_name) tool_configuration = ToolConfiguration(tenant_id=tanent_id, provider_controller=controller) - decrypted_credentails = tool_configuration.decrypt_tool_credentials(credentials) + decrypted_credentials = tool_configuration.decrypt_tool_credentials(credentials) return builtin_tool.fork_tool_runtime(meta={ 'tenant_id': tanent_id, - 'credentials': decrypted_credentails, + 'credentials': decrypted_credentials, 'runtime_parameters': {} }, agent_callback=agent_callback) @@ -191,11 +191,11 @@ class ToolManager: # decrypt the credentials tool_configuration = ToolConfiguration(tenant_id=tanent_id, provider_controller=api_provider) - decrypted_credentails = tool_configuration.decrypt_tool_credentials(credentials) + decrypted_credentials = tool_configuration.decrypt_tool_credentials(credentials) return api_provider.get_tool(tool_name).fork_tool_runtime(meta={ 'tenant_id': tanent_id, - 'credentials': decrypted_credentails, + 'credentials': decrypted_credentials, }) elif provider_type == 'app': raise NotImplementedError('app provider not implemented') @@ -295,7 +295,7 @@ class ToolManager: ) # get credentials schema - schema = provider.get_credentails_schema() + schema = provider.get_credentials_schema() for name, value in schema.items(): result_providers[provider.identity.name].team_credentials[name] = \ ToolProviderCredentials.CredentialsType.defaut(value.type) @@ -311,7 +311,7 @@ class ToolManager: for db_builtin_provider in db_builtin_providers: # add provider into providers - credentails = db_builtin_provider.credentials + credentials = db_builtin_provider.credentials provider_name = db_builtin_provider.provider result_providers[provider_name].is_team_authorization = True @@ -321,8 +321,8 @@ class ToolManager: # init tool configuration tool_configuration = ToolConfiguration(tenant_id=tenant_id, provider_controller=controller) # decrypt the credentials and mask the credentials - decrypted_credentails = tool_configuration.decrypt_tool_credentials(credentials=credentails) - masked_credentials = tool_configuration.mask_tool_credentials(credentials=decrypted_credentails) + decrypted_credentials = tool_configuration.decrypt_tool_credentials(credentials=credentials) + masked_credentials = tool_configuration.mask_tool_credentials(credentials=decrypted_credentials) result_providers[provider_name].team_credentials = masked_credentials @@ -337,7 +337,7 @@ class ToolManager: except Exception as e: logger.error(f'failed to get user name for api provider {db_api_provider.id}: {str(e)}') # add provider into providers - credentails = db_api_provider.credentials + credentials = db_api_provider.credentials provider_name = db_api_provider.name result_providers[provider_name] = UserToolProvider( id=db_api_provider.id, @@ -367,8 +367,8 @@ class ToolManager: tool_configuration = ToolConfiguration(tenant_id=tenant_id, provider_controller=controller) # decrypt the credentials and mask the credentials - decrypted_credentails = tool_configuration.decrypt_tool_credentials(credentials=credentails) - masked_credentials = tool_configuration.mask_tool_credentials(credentials=decrypted_credentails) + decrypted_credentials = tool_configuration.decrypt_tool_credentials(credentials=credentials) + masked_credentials = tool_configuration.mask_tool_credentials(credentials=decrypted_credentials) result_providers[provider_name].team_credentials = masked_credentials @@ -426,8 +426,8 @@ class ToolManager: # init tool configuration tool_configuration = ToolConfiguration(tenant_id=tenant_id, provider_controller=controller) - decrypted_credentails = tool_configuration.decrypt_tool_credentials(credentials) - masked_credentials = tool_configuration.mask_tool_credentials(decrypted_credentails) + decrypted_credentials = tool_configuration.decrypt_tool_credentials(credentials) + masked_credentials = tool_configuration.mask_tool_credentials(decrypted_credentials) try: icon = json.loads(provider.icon) diff --git a/api/core/tools/utils/configration.py b/api/core/tools/utils/configration.py index a0ff8d754f..29c2a53ff4 100644 --- a/api/core/tools/utils/configration.py +++ b/api/core/tools/utils/configration.py @@ -9,22 +9,22 @@ class ToolConfiguration(BaseModel): tenant_id: str provider_controller: ToolProviderController - def _deep_copy(self, credentails: Dict[str, str]) -> Dict[str, str]: + def _deep_copy(self, credentials: Dict[str, str]) -> Dict[str, str]: """ deep copy credentials """ - return {key: value for key, value in credentails.items()} + return {key: value for key, value in credentials.items()} - def encrypt_tool_credentials(self, credentails: Dict[str, str]) -> Dict[str, str]: + def encrypt_tool_credentials(self, credentials: Dict[str, str]) -> Dict[str, str]: """ encrypt tool credentials with tanent id return a deep copy of credentials with encrypted values """ - credentials = self._deep_copy(credentails) + credentials = self._deep_copy(credentials) # get fields need to be decrypted - fields = self.provider_controller.get_credentails_schema() + fields = self.provider_controller.get_credentials_schema() for field_name, field in fields.items(): if field.type == ToolProviderCredentials.CredentialsType.SECRET_INPUT: if field_name in credentials: @@ -42,7 +42,7 @@ class ToolConfiguration(BaseModel): credentials = self._deep_copy(credentials) # get fields need to be decrypted - fields = self.provider_controller.get_credentails_schema() + fields = self.provider_controller.get_credentials_schema() for field_name, field in fields.items(): if field.type == ToolProviderCredentials.CredentialsType.SECRET_INPUT: if field_name in credentials: @@ -65,7 +65,7 @@ class ToolConfiguration(BaseModel): credentials = self._deep_copy(credentials) # get fields need to be decrypted - fields = self.provider_controller.get_credentails_schema() + fields = self.provider_controller.get_credentials_schema() for field_name, field in fields.items(): if field.type == ToolProviderCredentials.CredentialsType.SECRET_INPUT: if field_name in credentials: diff --git a/api/migrations/versions/8ec536f3c800_rename_api_provider_credentails.py b/api/migrations/versions/8ec536f3c800_rename_api_provider_credentails.py index 1380512f30..6cab1f2092 100644 --- a/api/migrations/versions/8ec536f3c800_rename_api_provider_credentails.py +++ b/api/migrations/versions/8ec536f3c800_rename_api_provider_credentails.py @@ -1,4 +1,4 @@ -"""rename api provider credentails +"""rename api provider credentials Revision ID: 8ec536f3c800 Revises: ad472b61a054 diff --git a/api/services/tools_manage_service.py b/api/services/tools_manage_service.py index ee530b1c1a..a866cbb4f9 100644 --- a/api/services/tools_manage_service.py +++ b/api/services/tools_manage_service.py @@ -112,7 +112,7 @@ class ToolManageService: except Exception as e: raise ValueError(f'invalid schema: {str(e)}') - credentails_schema = [ + credentials_schema = [ ToolProviderCredentials( name='auth_type', type=ToolProviderCredentials.CredentialsType.SELECT, @@ -163,7 +163,7 @@ class ToolManageService: { 'schema_type': schema_type, 'parameters_schema': tool_bundles, - 'credentials_schema': credentails_schema, + 'credentials_schema': credentials_schema, 'warning': warnings } ))