Skip to content

Commit ecfca9e

Browse files
first:
1 parent f18fa14 commit ecfca9e

File tree

6 files changed

+108
-16
lines changed

6 files changed

+108
-16
lines changed

manifest.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
version: 0.0.1
1+
version: 0.0.2
22
type: plugin
33
author: lemilemio
4-
name: dify-plugin-markdown-to-excel
4+
name: excel-plugin
55
label:
6-
en_US: dify-plugin-markdown-to-excel
7-
ja_JP: dify-plugin-markdown-to-excel
8-
zh_Hans: dify-plugin-markdown-to-excel
9-
pt_BR: dify-plugin-markdown-to-excel
6+
en_US: excel-plugin
7+
ja_JP: excel-plugin
8+
zh_Hans: excel-plugin
9+
pt_BR: excel-plugin
1010
description:
11-
en_US: markdown_to_excel
12-
ja_JP: markdown_to_excel
13-
zh_Hans: markdown_to_excel
14-
pt_BR: markdown_to_excel
11+
en_US: excel-plugin
12+
ja_JP: excel-plugin
13+
zh_Hans: excel-plugin
14+
pt_BR: excel-plugin
1515
icon: icon.svg
1616
resource:
1717
memory: 268435456
@@ -25,7 +25,7 @@ resource:
2525
size: 1048576
2626
plugins:
2727
tools:
28-
- provider/dify-plugin-markdown-to-excel.yaml
28+
- provider/excel-plugin.yaml
2929
meta:
3030
version: 0.0.2
3131
arch:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dify_plugin.errors.tool import ToolProviderCredentialValidationError
55

66

7-
class DifyPluginMarkdownToExcelProvider(ToolProvider):
7+
class ExcelPluginProvider(ToolProvider):
88
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
99
try:
1010
"""

provider/dify-plugin-markdown-to-excel.yaml renamed to provider/excel-plugin.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ identity:
66
zh_Hans: dify-plugin-markdown-to-excel
77
pt_BR: dify-plugin-markdown-to-excel
88
description:
9-
en_US: markdown_to_excel
10-
zh_Hans: markdown_to_excel
11-
pt_BR: markdown_to_excel
9+
en_US: Excel-Plugin
10+
zh_Hans: Excel-Plugin
11+
pt_BR: Excel-Plugin
1212
icon: icon.svg
1313
tools:
1414
- tools/dify-plugin-markdown-to-excel.yaml
15+
- tools/dify-plugin-excel-to-xml.yaml
1516
extra:
1617
python:
17-
source: provider/dify-plugin-markdown-to-excel.py
18+
source: provider/excel-plugin.py

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
dify_plugin
22
openpyxl
33
pandas
4+
requests
5+
lxml

tools/dify-plugin-excel-to-xml.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from collections.abc import Generator
2+
from typing import Any
3+
import pandas as pd
4+
from io import BytesIO
5+
import json
6+
import requests
7+
from urllib.parse import urlparse
8+
9+
from dify_plugin import Tool
10+
from dify_plugin.entities.tool import ToolInvokeMessage
11+
12+
class DifyPluginExcelToXMLTool(Tool):
13+
def _invoke(self, tool_parameters: dict[str, Any]) -> Generator[ToolInvokeMessage, None, None]:
14+
# ファイルURLを取得
15+
file_url = tool_parameters.get("file_url", "")
16+
if not file_url:
17+
yield ToolInvokeMessage(
18+
type="text",
19+
message={"text": "ファイルURLが提供されていません。"}
20+
)
21+
return
22+
23+
try:
24+
# URLの検証
25+
parsed_url = urlparse(file_url)
26+
if not parsed_url.scheme or not parsed_url.netloc:
27+
raise ValueError("無効なURLです")
28+
29+
# ファイルをダウンロード
30+
response = requests.get(file_url)
31+
response.raise_for_status()
32+
33+
# ExcelファイルをPandasで読み込む
34+
excel_data = BytesIO(response.content)
35+
df = pd.read_excel(excel_data)
36+
37+
# XMLに変換
38+
xml_data = df.to_xml(index=False, root_name="data", row_name="row")
39+
40+
# XML形式のテキストを返す
41+
yield ToolInvokeMessage(
42+
type="text",
43+
message={"text": xml_data}
44+
)
45+
46+
except requests.exceptions.RequestException as e:
47+
yield ToolInvokeMessage(
48+
type="text",
49+
message={"text": f"ファイルのダウンロードに失敗しました: {str(e)}"}
50+
)
51+
except Exception as e:
52+
yield ToolInvokeMessage(
53+
type="text",
54+
message={"text": f"エラーが発生しました: {str(e)}"}
55+
)
56+
return
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
identity:
2+
name: excel_to_xml
3+
author: Dify
4+
label:
5+
en_US: Excel to XML
6+
ja_JP: ExcelからXML
7+
zh_Hans: Excel转XML
8+
9+
description:
10+
human:
11+
en_US: Convert Excel file to XML format text
12+
ja_JP: ExcelファイルをXML形式のテキストに変換します
13+
zh_Hans: 将Excel文件转换为XML格式文本
14+
llm: A tool for converting Excel files to XML format text
15+
16+
parameters:
17+
- name: file_url
18+
type: file
19+
required: true
20+
label:
21+
en_US: Excel File URL
22+
ja_JP: ExcelファイルのURL
23+
zh_Hans: Excel文件URL
24+
human_description:
25+
en_US: The URL of the Excel file to convert
26+
ja_JP: 変換するExcelファイルのURL
27+
zh_Hans: 需要转换的Excel文件的URL
28+
llm_description: The URL of the Excel file that needs to be converted to XML format
29+
form: llm
30+
31+
extra:
32+
python:
33+
source: tools/dify-plugin-excel-to-xml.py

0 commit comments

Comments
 (0)