-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from suluyana/refactor/tool/image_gen
Refactor/tool/image_gen
- Loading branch information
Showing
3 changed files
with
59 additions
and
106 deletions.
There are no files selected for viewing
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,39 @@ | ||
from modelscope_agent.agent import Agent | ||
from modelscope_agent.tools.text_to_image_tool import TextToImageTool | ||
|
||
from modelscope_agent.prompts.role_play import RolePlay # NOQA | ||
|
||
|
||
def test_image_gen(): | ||
params = """{'text': '画一只小猫', 'resolution': '1024*1024'}""" | ||
|
||
t2i = TextToImageTool() | ||
res = t2i.call(params) | ||
assert (res.startswith('http')) | ||
|
||
|
||
def test_image_gen_wrong_resolution(): | ||
params = """{'text': '画一只小猫', 'resolution': '1024'}""" | ||
|
||
t2i = TextToImageTool() | ||
res = t2i.call(params) | ||
assert (res.startswith('http')) | ||
|
||
|
||
def test_image_gen_role(): | ||
role_template = '你扮演一个画家,用尽可能丰富的描述调用工具绘制图像。' | ||
|
||
llm_config = {'model': 'qwen-max', 'model_server': 'dashscope'} | ||
|
||
# input tool args | ||
function_list = [{'name': 'image_gen'}] | ||
|
||
bot = RolePlay( | ||
function_list=function_list, llm=llm_config, instruction=role_template) | ||
|
||
response = bot.run('朝阳区天气怎样?') | ||
|
||
text = '' | ||
for chunk in response: | ||
text += chunk | ||
print(text) |
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