forked from modelscope/agentscope
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
700 additions
and
20 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/agentscope/studio/static/html-drag-components/agent-broadcastagent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div> | ||
<div class="title-box" data-class="BroadcastAgent"> | ||
<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="M21.344 448h85.344v234.656H21.344V448zM554.656 192h64V106.656h-213.344V192h64v42.656h-320V896h725.344V234.656h-320V192z m234.688 128v490.656H234.688V320h554.656zM917.344 448h85.344v234.656h-85.344V448z"></path> | ||
<path d="M341.344 512H448v106.656h-106.656V512zM576 512h106.656v106.656H576V512z"></path> | ||
</svg> | ||
<span>BroadcastAgent</span> | ||
</div> | ||
<button class="button copy-button" | ||
i18n="agent-broadcast-Copy">Copy</button> | ||
<span class="toggle-arrow">▲</span></div> | ||
<div class="box"> | ||
<div class="readme"> | ||
<span i18n="agent-broadcast-readme"> | ||
An agent that only broadcasts its content | ||
</span> | ||
<div>Node ID: <span class="node-id">ID_PLACEHOLDER</span></div> | ||
</div> | ||
|
||
<label i18n="agent-broadcast-labelName">Name</label> | ||
<input type="text" df-args-name placeholder="Assistant" | ||
i18n="agent-broadcast-labelName-Assistant" | ||
data-required="true"> | ||
<br> | ||
|
||
<label i18n="agent-broadcast-content">content</label> | ||
<textarea type="text" df-args-content class="text-input" | ||
data-required="true"></textarea> | ||
</div> | ||
</div> |
19 changes: 19 additions & 0 deletions
19
src/agentscope/studio/static/html-drag-components/agent-copyagent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div> | ||
<div class="title-box" data-class="node-DialogAgent"> | ||
<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="M21.344 448h85.344v234.656H21.344V448zM554.656 192h64V106.656h-213.344V192h64v42.656h-320V896h725.344V234.656h-320V192z m234.688 128v490.656H234.688V320h554.656zM917.344 448h85.344v234.656h-85.344V448z"></path> | ||
<path d="M341.344 512H448v106.656h-106.656V512zM576 512h106.656v106.656H576V512z"></path> | ||
</svg> | ||
<span>NAME_PLACEHOLDER</span> | ||
</div> | ||
<span class="toggle-arrow">▲</span></div> | ||
<div class="box"> | ||
<div class="readme"> | ||
README_PLACEHOLDER | ||
<div>Copy from Node ID: | ||
<span class="node-id">ID_PLACEHOLDER</span></div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
"""A dummy agent.""" | ||
from typing import Optional, Union, Sequence | ||
|
||
from agentscope.agents import AgentBase | ||
from agentscope.message import Msg | ||
|
||
|
||
class BroadcastAgent(AgentBase): | ||
"""A dummy agent used to only speak what he gets.""" | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
content: str, | ||
sys_prompt: str = None, | ||
model_config_name: str = None, | ||
use_memory: bool = False, | ||
memory_config: Optional[dict] = None, | ||
) -> None: | ||
"""Initialize the dummy agent. | ||
Arguments: | ||
name (`str`): | ||
The name of the agent. | ||
sys_prompt (`Optional[str]`): | ||
The system prompt of the agent, which can be passed by args | ||
or hard-coded in the agent. | ||
model_config_name (`str`): | ||
The name of the model config, which is used to load model from | ||
configuration. | ||
use_memory (`bool`, defaults to `True`): | ||
Whether the agent has memory. | ||
memory_config (`Optional[dict]`): | ||
The config of memory. | ||
""" | ||
super().__init__( | ||
name=name, | ||
sys_prompt=sys_prompt, | ||
model_config_name=model_config_name, | ||
use_memory=use_memory, | ||
memory_config=memory_config, | ||
) | ||
self.content = content | ||
|
||
def reply(self, x: Optional[Union[Msg, Sequence[Msg]]] = None) -> Msg: | ||
"""Reply function of the agent. Processes the input data, | ||
generates a prompt using the current dialogue memory and system | ||
prompt, and invokes the language model to produce a response. The | ||
response is then formatted and added to the dialogue memory. | ||
Args: | ||
x (`Optional[Union[Msg, Sequence[Msg]]]`, defaults to `None`): | ||
The input message(s) to the agent, which also can be omitted if | ||
the agent doesn't need any input. | ||
Returns: | ||
`Msg`: The output message generated by the agent. | ||
""" | ||
|
||
# Print/speak the message in this agent's voice | ||
# Support both streaming and non-streaming responses by "or" | ||
x = Msg(name=self.name, content=self.content, role="assistant") | ||
self.speak(x) | ||
|
||
return x |
Oops, something went wrong.