Skip to content

Commit

Permalink
Add support of html configs when running as_gradio command (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
qbc2016 authored Aug 21, 2024
1 parent 3ed447b commit 9696bb5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/agentscope/studio/static/js/workstation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,7 @@ function showExportHTMLPopup() {

// Remove the html attribute from the nodes to avoid inconsistencies in html
removeHtmlFromUsers(rawData);
sortElementsByPosition(rawData);

const exportData = JSON.stringify(rawData, null, 4);

Expand Down
16 changes: 16 additions & 0 deletions src/agentscope/web/workstation/workflow_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,22 @@ def build_dag(config: dict) -> ASDiGraph:
"""
dag = ASDiGraph()

# for html json file,
# retrieve the contents of config["drawflow"]["Home"]["data"],
# and remove the node whose class is "welcome"
if (
"drawflow" in config
and "Home" in config["drawflow"]
and "data" in config["drawflow"]["Home"]
):
config = config["drawflow"]["Home"]["data"]

config = {
k: v
for k, v in config.items()
if not ("class" in v and v["class"] == "welcome")
}

for node_id, node_info in config.items():
config[node_id] = sanitize_node_data(node_info)

Expand Down
10 changes: 5 additions & 5 deletions src/agentscope/web/workstation/workflow_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def __init__(

def compile(self) -> dict:
return {
"imports": "from agentscope.service import ServiceFactory\n"
"imports": "from agentscope.service import ServiceToolkit\n"
"from functools import partial\n"
"from agentscope.service import bing_search",
"inits": f"{self.var_name} = partial(bing_search,"
Expand Down Expand Up @@ -745,7 +745,7 @@ def __init__(

def compile(self) -> dict:
return {
"imports": "from agentscope.service import ServiceFactory\n"
"imports": "from agentscope.service import ServiceToolkit\n"
"from functools import partial\n"
"from agentscope.service import google_search",
"inits": f"{self.var_name} = partial(google_search,"
Expand Down Expand Up @@ -773,7 +773,7 @@ def __init__(

def compile(self) -> dict:
return {
"imports": "from agentscope.service import ServiceFactory\n"
"imports": "from agentscope.service import ServiceToolkit\n"
"from agentscope.service import execute_python_code",
"inits": f"{self.var_name} = execute_python_code",
"execs": "",
Expand All @@ -799,7 +799,7 @@ def __init__(

def compile(self) -> dict:
return {
"imports": "from agentscope.service import ServiceFactory\n"
"imports": "from agentscope.service import ServiceToolkit\n"
"from agentscope.service import read_text_file",
"inits": f"{self.var_name} = read_text_file",
"execs": "",
Expand All @@ -825,7 +825,7 @@ def __init__(

def compile(self) -> dict:
return {
"imports": "from agentscope.service import ServiceFactory\n"
"imports": "from agentscope.service import ServiceToolkit\n"
"from agentscope.service import write_text_file",
"inits": f"{self.var_name} = write_text_file",
"execs": "",
Expand Down

0 comments on commit 9696bb5

Please sign in to comment.