mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 02:29:05 +08:00
feat: support extracting plugins into local files
This commit is contained in:
parent
0249f15609
commit
23066a9ba8
@ -661,12 +661,13 @@ def migrate_data_for_plugin():
|
|||||||
|
|
||||||
|
|
||||||
@click.command("extract-plugins", help="Extract plugins.")
|
@click.command("extract-plugins", help="Extract plugins.")
|
||||||
def extract_plugins():
|
@click.option("--output_file", prompt=True, help="The file to store the extracted plugins.")
|
||||||
|
def extract_plugins(output_file: str):
|
||||||
"""
|
"""
|
||||||
Extract plugins.
|
Extract plugins.
|
||||||
"""
|
"""
|
||||||
click.echo(click.style("Starting extract plugins.", fg="white"))
|
click.echo(click.style("Starting extract plugins.", fg="white"))
|
||||||
|
|
||||||
PluginMigration.extract_plugins()
|
PluginMigration.extract_plugins(output_file)
|
||||||
|
|
||||||
click.echo(click.style("Extract plugins completed.", fg="green"))
|
click.echo(click.style("Extract plugins completed.", fg="green"))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ excluded_providers = ["time", "audio", "code", "webscraper"]
|
|||||||
|
|
||||||
class PluginMigration:
|
class PluginMigration:
|
||||||
@classmethod
|
@classmethod
|
||||||
def extract_plugins(cls) -> None:
|
def extract_plugins(cls, filepath: str) -> None:
|
||||||
"""
|
"""
|
||||||
Migrate plugin.
|
Migrate plugin.
|
||||||
"""
|
"""
|
||||||
@ -94,7 +95,9 @@ class PluginMigration:
|
|||||||
|
|
||||||
for tenant_id in tenants:
|
for tenant_id in tenants:
|
||||||
plugins = cls.extract_installed_plugin_ids(tenant_id)
|
plugins = cls.extract_installed_plugin_ids(tenant_id)
|
||||||
print(plugins)
|
# append to file, it's a jsonl file
|
||||||
|
with open(filepath, "a") as f:
|
||||||
|
f.write(json.dumps({"tenant_id": tenant_id, "plugins": plugins}) + "\n")
|
||||||
|
|
||||||
handled_tenant_count += len(tenants)
|
handled_tenant_count += len(tenants)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user