fix: the Image-1X tool (#8787)

This commit is contained in:
非法操作 2024-09-26 13:48:06 +08:00 committed by GitHub
parent a0b0809b1c
commit d1173a69f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 56 deletions

View File

@ -16,7 +16,7 @@ class StepfunProvider(BuiltinToolProviderController):
user_id="", user_id="",
tool_parameters={ tool_parameters={
"prompt": "cute girl, blue eyes, white hair, anime style", "prompt": "cute girl, blue eyes, white hair, anime style",
"size": "1024x1024", "size": "256x256",
"n": 1, "n": 1,
}, },
) )

View File

@ -4,11 +4,9 @@ identity:
label: label:
en_US: Image-1X en_US: Image-1X
zh_Hans: 阶跃星辰绘画 zh_Hans: 阶跃星辰绘画
pt_BR: Image-1X
description: description:
en_US: Image-1X en_US: Image-1X
zh_Hans: 阶跃星辰绘画 zh_Hans: 阶跃星辰绘画
pt_BR: Image-1X
icon: icon.png icon: icon.png
tags: tags:
- image - image
@ -20,27 +18,16 @@ credentials_for_provider:
label: label:
en_US: Stepfun API key en_US: Stepfun API key
zh_Hans: 阶跃星辰API key zh_Hans: 阶跃星辰API key
pt_BR: Stepfun API key
help:
en_US: Please input your stepfun API key
zh_Hans: 请输入你的阶跃星辰 API key
pt_BR: Please input your stepfun API key
placeholder: placeholder:
en_US: Please input your stepfun API key en_US: Please input your Stepfun API key
zh_Hans: 请输入你的阶跃星辰 API key zh_Hans: 请输入你的阶跃星辰 API key
pt_BR: Please input your stepfun API key url: https://platform.stepfun.com/interface-key
stepfun_base_url: stepfun_base_url:
type: text-input type: text-input
required: false required: false
label: label:
en_US: Stepfun base URL en_US: Stepfun base URL
zh_Hans: 阶跃星辰 base URL zh_Hans: 阶跃星辰 base URL
pt_BR: Stepfun base URL
help:
en_US: Please input your Stepfun base URL
zh_Hans: 请输入你的阶跃星辰 base URL
pt_BR: Please input your Stepfun base URL
placeholder: placeholder:
en_US: Please input your Stepfun base URL en_US: Please input your Stepfun base URL
zh_Hans: 请输入你的阶跃星辰 base URL zh_Hans: 请输入你的阶跃星辰 base URL
pt_BR: Please input your Stepfun base URL

View File

@ -1,4 +1,3 @@
import random
from typing import Any, Union from typing import Any, Union
from openai import OpenAI from openai import OpenAI
@ -19,7 +18,7 @@ class StepfunTool(BuiltinTool):
""" """
invoke tools invoke tools
""" """
base_url = self.runtime.credentials.get("stepfun_base_url", "https://api.stepfun.com") base_url = self.runtime.credentials.get("stepfun_base_url") or "https://api.stepfun.com"
base_url = str(URL(base_url) / "v1") base_url = str(URL(base_url) / "v1")
client = OpenAI( client = OpenAI(
@ -28,9 +27,7 @@ class StepfunTool(BuiltinTool):
) )
extra_body = {} extra_body = {}
model = tool_parameters.get("model", "step-1x-medium") model = "step-1x-medium"
if not model:
return self.create_text_message("Please input model name")
# prompt # prompt
prompt = tool_parameters.get("prompt", "") prompt = tool_parameters.get("prompt", "")
if not prompt: if not prompt:
@ -67,9 +64,3 @@ class StepfunTool(BuiltinTool):
) )
) )
return result return result
@staticmethod
def _generate_random_id(length=8):
characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
random_id = "".join(random.choices(characters, k=length))
return random_id

View File

@ -29,35 +29,6 @@ parameters:
pt_BR: Image prompt, you can check the official documentation of step-1x pt_BR: Image prompt, you can check the official documentation of step-1x
llm_description: Image prompt of step-1x you should describe the image you want to generate as a list of words as possible as detailed llm_description: Image prompt of step-1x you should describe the image you want to generate as a list of words as possible as detailed
form: llm form: llm
- name: model
type: select
required: false
human_description:
en_US: used for selecting the model name
zh_Hans: 用于选择模型的名字
pt_BR: used for selecting the model name
label:
en_US: Model Name
zh_Hans: 模型名字
pt_BR: Model Name
form: form
options:
- value: step-1x-turbo
label:
en_US: turbo
zh_Hans: turbo
pt_BR: turbo
- value: step-1x-medium
label:
en_US: medium
zh_Hans: medium
pt_BR: medium
- value: step-1x-large
label:
en_US: large
zh_Hans: large
pt_BR: large
default: step-1x-medium
- name: size - name: size
type: select type: select
required: false required: false