Skip to content

Commit

Permalink
support wanx (modelscope#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
qbc2016 authored Aug 20, 2024
1 parent df3d38c commit d54d178
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/agentscope/studio/static/html-drag-components/model-wanx.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div class="title-box" data-class="Wanx">
<div class="title-box-left-items">
<svg class="title-box-svg" viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg">
<path d="M847.530667 361.173333a149.546667 149.546667 0 0 0-129.28-189.824A128.213333 128.213333 0 0 0 597.333333 85.333333a127.146667 127.146667 0 0 0-85.333333 33.28A127.146667 127.146667 0 0 0 426.666667 85.333333c-55.509333 0-102.826667 35.456-120.533334 85.973334a149.546667 149.546667 0 0 0-129.664 189.866666A171.861333 171.861333 0 0 0 85.333333 512c0 45.866667 18.261333 89.002667 50.005334 120.832A173.525333 173.525333 0 0 0 128 682.666667c0 83.498667 60.245333 153.173333 141.056 167.850666A149.973333 149.973333 0 0 0 405.333333 938.666667c41.770667 0 79.530667-17.365333 106.666667-45.184A148.650667 148.650667 0 0 0 618.666667 938.666667a149.76 149.76 0 0 0 136.106666-87.893334 170.922667 170.922667 0 0 0 133.888-217.941333A170.794667 170.794667 0 0 0 938.666667 512a171.861333 171.861333 0 0 0-91.136-150.826667zM405.333333 853.333333c-30.336 0-56.746667-21.504-62.72-51.114666L333.568 768H298.666667c-47.061333 0-85.333333-38.272-85.333334-85.333333 0-15.018667 3.626667-29.098667 10.794667-41.856l19.456-34.816-33.450667-21.76A86.144 86.144 0 0 1 170.666667 512c0-41.685333 30.848-77.824 71.765333-84.138667l72.234667-11.093333-45.184-57.429333a64.085333 64.085333 0 0 1 63.914666-101.973334L384 264.832V213.333333a42.666667 42.666667 0 0 1 85.333333 0v576c0 35.285333-28.714667 64-64 64z m408.533334-269.141333l-33.450667 21.76 19.456 34.816c7.168 12.8 10.794667 26.88 10.794667 41.898667 0 47.061333-38.272 85.333333-87.466667 85.333333h-34.901333l-6.912 34.218667A64.085333 64.085333 0 0 1 618.666667 853.333333c-35.285333 0-64-28.714667-64-64V213.333333c0-23.552 19.114667-42.666667 42.666666-42.666666s42.666667 19.114667 42.666667 44.8v51.498666l50.602667-9.6a64.085333 64.085333 0 0 1 63.914666 101.973334l-45.184 57.472 72.234667 11.093333A85.418667 85.418667 0 0 1 853.333333 512c0 29.141333-14.762667 56.106667-39.466666 72.192z"></path>
</svg>
<span>Wanx</span>
</div>
<span class="toggle-arrow">&#x25B2;</span>
</div>
<div class="box">
<div class="readme">Wanx Configurations</div>
<br>
<label> Config Name </label>
<input type="text" df-args-config_name placeholder="wanx"
data-required="true"><br>
<label> Model Name </label>
<input type="text" df-args-model_name placeholder="wanx-v1"
data-required="true"><br>
<label>API key</label>
<input type="text" df-args-api_key data-required="true"><br>
<label> Number of Images </label>
<input type="number" df-args-generate_args-n placeholder=1
data-required="true"><br>
<label> size </label>
<input type="text" list="wanx-image-sizes" df-args-generate_args-size
data-required="true"><br>
<datalist id="wanx-image-sizes">
<option value="1024*1024">
<option value="720*1280">
<option value="1280*720">
</datalist>
<label> Temperature </label>
<input type="number" df-args-generate_args-temperature placeholder=0
min="0" max="2" step="0.1"><br>
<label> Seed </label>
<input type="number" df-args-generate_args-seed placeholder=0 min="0" max="4">
<label> Messages Key </label>
<input type="text" df-args-messages_key placeholder="prompt"><br>
</div>
23 changes: 23 additions & 0 deletions src/agentscope/studio/static/js/workstation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let nameToHtmlFile = {
'openai_chat': 'model-openai-chat.html',
'post_api_chat': 'model-post-api-chat.html',
'post_api_dall_e': 'model-post-api-dall-e.html',
'dashscope_image_synthesis': 'model-wanx.html',
'Message': 'message-msg.html',
'DialogAgent': 'agent-dialogagent.html',
'UserAgent': 'agent-useragent.html',
Expand Down Expand Up @@ -562,6 +563,28 @@ async function addNodeToDrawFlow(name, pos_x, pos_y) {
addEventListenersToNumberInputs(post_api_dall_eId);
break;

case 'dashscope_image_synthesis':
const dashscope_image_synthesisId = editor.addNode('dashscope_image_synthesis', 0,
0,
pos_x, pos_y,
'dashscope_image_synthesis', {
"args":
{
"config_name": '',
"model_name": '',
"generate_args": {
"n": 1,
"size": "",
"temperature": 0.0,
"seed": 0,
},
"model_type": 'dashscope_image_synthesis',
"messages_key": 'prompt'
}
}, htmlSourceCode);
addEventListenersToNumberInputs(dashscope_image_synthesisId);
break;

// Message
case 'Message':
editor.addNode('Message', 1, 1, pos_x,
Expand Down
19 changes: 18 additions & 1 deletion src/agentscope/studio/templates/workstation.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
data-node="post_api_dall_e" draggable="true"
ondragstart="drag(event)">Post API Dall-E
</li>
<li class="workstation-sidebar-dragitem"
data-node="dashscope_image_synthesis" draggable="true"
ondragstart="drag(event)">Wanx
</li>
</ul>
</li>
<li>
Expand Down Expand Up @@ -209,7 +213,7 @@
<li>
<div class="workstation-sidebar-subitem unselectable-text"
onclick="onClickSidebarSubItem(this);">
Tool
Service
</div>
<ul class="workstation-sidebar-sub-content">
<li class="workstation-sidebar-dragitem unselectable-text"
Expand Down Expand Up @@ -239,6 +243,19 @@
</li>
</ul>
</li>
<li>
<div class="workstation-sidebar-subitem unselectable-text"
onclick="onClickSidebarSubItem(this);">
Tool
</div>
<ul class="workstation-sidebar-sub-content">
<li class="workstation-sidebar-dragitem unselectable-text"
data-node="ImageComposition"
draggable="true" ondragstart="drag(event)">
Image Composition
</li>
</ul>
</li>
</ul>
</li>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/agentscope/web/workstation/workflow_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ def compile(self) -> dict:
"openai_chat": ModelNode,
"post_api_chat": ModelNode,
"post_api_dall_e": ModelNode,
'dashscope_image_synthesis': ModelNode,
"Message": MsgNode,
"DialogAgent": DialogAgentNode,
"UserAgent": UserAgentNode,
Expand Down

0 comments on commit d54d178

Please sign in to comment.