插件
This commit is contained in:
53
difyPlugin/pdf/provider/pdf.py
Normal file
53
difyPlugin/pdf/provider/pdf.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from typing import Any
|
||||
|
||||
from dify_plugin import ToolProvider
|
||||
from dify_plugin.errors.tool import ToolProviderCredentialValidationError
|
||||
|
||||
|
||||
class PdfProvider(ToolProvider):
|
||||
|
||||
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
|
||||
try:
|
||||
"""
|
||||
IMPLEMENT YOUR VALIDATION HERE
|
||||
"""
|
||||
except Exception as e:
|
||||
raise ToolProviderCredentialValidationError(str(e))
|
||||
|
||||
#########################################################################################
|
||||
# If OAuth is supported, uncomment the following functions.
|
||||
# Warning: please make sure that the sdk version is 0.4.2 or higher.
|
||||
#########################################################################################
|
||||
# def _oauth_get_authorization_url(self, redirect_uri: str, system_credentials: Mapping[str, Any]) -> str:
|
||||
# """
|
||||
# Generate the authorization URL for pdf OAuth.
|
||||
# """
|
||||
# try:
|
||||
# """
|
||||
# IMPLEMENT YOUR AUTHORIZATION URL GENERATION HERE
|
||||
# """
|
||||
# except Exception as e:
|
||||
# raise ToolProviderOAuthError(str(e))
|
||||
# return ""
|
||||
|
||||
# def _oauth_get_credentials(
|
||||
# self, redirect_uri: str, system_credentials: Mapping[str, Any], request: Request
|
||||
# ) -> Mapping[str, Any]:
|
||||
# """
|
||||
# Exchange code for access_token.
|
||||
# """
|
||||
# try:
|
||||
# """
|
||||
# IMPLEMENT YOUR CREDENTIALS EXCHANGE HERE
|
||||
# """
|
||||
# except Exception as e:
|
||||
# raise ToolProviderOAuthError(str(e))
|
||||
# return dict()
|
||||
|
||||
# def _oauth_refresh_credentials(
|
||||
# self, redirect_uri: str, system_credentials: Mapping[str, Any], credentials: Mapping[str, Any]
|
||||
# ) -> OAuthCredentials:
|
||||
# """
|
||||
# Refresh the credentials
|
||||
# """
|
||||
# return OAuthCredentials(credentials=credentials, expires_at=-1)
|
||||
63
difyPlugin/pdf/provider/pdf.yaml
Normal file
63
difyPlugin/pdf/provider/pdf.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
identity:
|
||||
author: "yslg"
|
||||
name: "pdf"
|
||||
label:
|
||||
en_US: "pdf"
|
||||
zh_Hans: "pdf"
|
||||
pt_BR: "pdf"
|
||||
ja_JP: "pdf"
|
||||
description:
|
||||
en_US: "pdfTools"
|
||||
zh_Hans: "pdfTools"
|
||||
pt_BR: "pdfTools"
|
||||
ja_JP: "pdfTools"
|
||||
icon: "icon.svg"
|
||||
|
||||
#########################################################################################
|
||||
# If you want to support OAuth, you can uncomment the following code.
|
||||
#########################################################################################
|
||||
# oauth_schema:
|
||||
# client_schema:
|
||||
# - name: "client_id"
|
||||
# type: "secret-input"
|
||||
# required: true
|
||||
# url: https://example.com/oauth/authorize
|
||||
# placeholder:
|
||||
# en_US: "Please input your Client ID"
|
||||
# zh_Hans: "请输入你的 Client ID"
|
||||
# pt_BR: "Insira seu Client ID"
|
||||
# help:
|
||||
# en_US: "Client ID is used to authenticate requests to the example.com API."
|
||||
# zh_Hans: "Client ID 用于认证请求到 example.com API。"
|
||||
# pt_BR: "Client ID é usado para autenticar solicitações à API do example.com."
|
||||
# label:
|
||||
# zh_Hans: "Client ID"
|
||||
# en_US: "Client ID"
|
||||
# - name: "client_secret"
|
||||
# type: "secret-input"
|
||||
# required: true
|
||||
# url: https://example.com/oauth/authorize
|
||||
# placeholder:
|
||||
# en_US: "Please input your Client Secret"
|
||||
# zh_Hans: "请输入你的 Client Secret"
|
||||
# pt_BR: "Insira seu Client Secret"
|
||||
# help:
|
||||
# en_US: "Client Secret is used to authenticate requests to the example.com API."
|
||||
# zh_Hans: "Client Secret 用于认证请求到 example.com API。"
|
||||
# pt_BR: "Client Secret é usado para autenticar solicitações à API do example.com."
|
||||
# label:
|
||||
# zh_Hans: "Client Secret"
|
||||
# en_US: "Client Secret"
|
||||
# credentials_schema:
|
||||
# - name: "access_token"
|
||||
# type: "secret-input"
|
||||
# label:
|
||||
# zh_Hans: "Access Token"
|
||||
# en_US: "Access Token"
|
||||
|
||||
tools:
|
||||
- tools/pdf.yaml
|
||||
- tools/pdf_single_page.yaml
|
||||
extra:
|
||||
python:
|
||||
source: provider/pdf.py
|
||||
Reference in New Issue
Block a user