mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
update stepfun model (#7118)
Some checks failed
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Mark stale issues and pull requests / stale (push) Has been cancelled
Some checks failed
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Mark stale issues and pull requests / stale (push) Has been cancelled
Co-authored-by: chenlinfeng <chenlinfeng@step.ai> Co-authored-by: Tfsh <tianfs_fight@163.com>
This commit is contained in:
parent
7944ce0594
commit
07511dfaf4
|
@ -2,5 +2,7 @@
|
|||
- step-1-32k
|
||||
- step-1-128k
|
||||
- step-1-256k
|
||||
- step-1-flash
|
||||
- step-2-16k
|
||||
- step-1v-8k
|
||||
- step-1v-32k
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
model: step-1-flash
|
||||
label:
|
||||
zh_Hans: step-1-flash
|
||||
en_US: step-1-flash
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
model_properties:
|
||||
mode: chat
|
||||
context_size: 8000
|
||||
parameter_rules:
|
||||
- name: temperature
|
||||
use_template: temperature
|
||||
- name: top_p
|
||||
use_template: top_p
|
||||
- name: max_tokens
|
||||
use_template: max_tokens
|
||||
default: 512
|
||||
min: 1
|
||||
max: 8000
|
||||
pricing:
|
||||
input: '0.001'
|
||||
output: '0.004'
|
||||
unit: '0.001'
|
||||
currency: RMB
|
|
@ -5,6 +5,9 @@ label:
|
|||
model_type: llm
|
||||
features:
|
||||
- vision
|
||||
- tool-call
|
||||
- multi-tool-call
|
||||
- stream-tool-call
|
||||
model_properties:
|
||||
mode: chat
|
||||
context_size: 32000
|
||||
|
|
|
@ -5,6 +5,9 @@ label:
|
|||
model_type: llm
|
||||
features:
|
||||
- vision
|
||||
- tool-call
|
||||
- multi-tool-call
|
||||
- stream-tool-call
|
||||
model_properties:
|
||||
mode: chat
|
||||
context_size: 8192
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
model: step-2-16k
|
||||
label:
|
||||
zh_Hans: step-2-16k
|
||||
en_US: step-2-16k
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
- tool-call
|
||||
- multi-tool-call
|
||||
- stream-tool-call
|
||||
model_properties:
|
||||
mode: chat
|
||||
context_size: 16000
|
||||
parameter_rules:
|
||||
- name: temperature
|
||||
use_template: temperature
|
||||
- name: top_p
|
||||
use_template: top_p
|
||||
- name: max_tokens
|
||||
use_template: max_tokens
|
||||
default: 1024
|
||||
min: 1
|
||||
max: 16000
|
||||
pricing:
|
||||
input: '0.038'
|
||||
output: '0.120'
|
||||
unit: '0.001'
|
||||
currency: RMB
|
0
api/core/tools/provider/builtin/stepfun/__init__.py
Normal file
0
api/core/tools/provider/builtin/stepfun/__init__.py
Normal file
BIN
api/core/tools/provider/builtin/stepfun/_assets/icon.png
Normal file
BIN
api/core/tools/provider/builtin/stepfun/_assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
25
api/core/tools/provider/builtin/stepfun/stepfun.py
Normal file
25
api/core/tools/provider/builtin/stepfun/stepfun.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from typing import Any
|
||||
|
||||
from core.tools.errors import ToolProviderCredentialValidationError
|
||||
from core.tools.provider.builtin.stepfun.tools.image import StepfunTool
|
||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||
|
||||
|
||||
class StepfunProvider(BuiltinToolProviderController):
|
||||
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
|
||||
try:
|
||||
StepfunTool().fork_tool_runtime(
|
||||
runtime={
|
||||
"credentials": credentials,
|
||||
}
|
||||
).invoke(
|
||||
user_id='',
|
||||
tool_parameters={
|
||||
"prompt": "cute girl, blue eyes, white hair, anime style",
|
||||
"size": "1024x1024",
|
||||
"n": 1
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
raise ToolProviderCredentialValidationError(str(e))
|
||||
|
46
api/core/tools/provider/builtin/stepfun/stepfun.yaml
Normal file
46
api/core/tools/provider/builtin/stepfun/stepfun.yaml
Normal file
|
@ -0,0 +1,46 @@
|
|||
identity:
|
||||
author: Stepfun
|
||||
name: stepfun
|
||||
label:
|
||||
en_US: Image-1X
|
||||
zh_Hans: 阶跃星辰绘画
|
||||
pt_BR: Image-1X
|
||||
description:
|
||||
en_US: Image-1X
|
||||
zh_Hans: 阶跃星辰绘画
|
||||
pt_BR: Image-1X
|
||||
icon: icon.png
|
||||
tags:
|
||||
- image
|
||||
- productivity
|
||||
credentials_for_provider:
|
||||
stepfun_api_key:
|
||||
type: secret-input
|
||||
required: true
|
||||
label:
|
||||
en_US: Stepfun 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:
|
||||
en_US: Please input your stepfun API key
|
||||
zh_Hans: 请输入你的阶跃星辰 API key
|
||||
pt_BR: Please input your stepfun API key
|
||||
stepfun_base_url:
|
||||
type: text-input
|
||||
required: false
|
||||
label:
|
||||
en_US: Stepfun 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:
|
||||
en_US: Please input your Stepfun base URL
|
||||
zh_Hans: 请输入你的阶跃星辰 base URL
|
||||
pt_BR: Please input your Stepfun base URL
|
72
api/core/tools/provider/builtin/stepfun/tools/image.py
Normal file
72
api/core/tools/provider/builtin/stepfun/tools/image.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
import random
|
||||
from typing import Any, Union
|
||||
|
||||
from openai import OpenAI
|
||||
from yarl import URL
|
||||
|
||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||
from core.tools.tool.builtin_tool import BuiltinTool
|
||||
|
||||
|
||||
class StepfunTool(BuiltinTool):
|
||||
""" Stepfun Image Generation Tool """
|
||||
def _invoke(self,
|
||||
user_id: str,
|
||||
tool_parameters: dict[str, Any],
|
||||
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||
"""
|
||||
invoke tools
|
||||
"""
|
||||
base_url = self.runtime.credentials.get('stepfun_base_url', None)
|
||||
if not base_url:
|
||||
base_url = None
|
||||
else:
|
||||
base_url = str(URL(base_url) / 'v1')
|
||||
|
||||
client = OpenAI(
|
||||
api_key=self.runtime.credentials['stepfun_api_key'],
|
||||
base_url=base_url,
|
||||
)
|
||||
|
||||
extra_body = {}
|
||||
model = tool_parameters.get('model', 'step-1x-medium')
|
||||
if not model:
|
||||
return self.create_text_message('Please input model name')
|
||||
# prompt
|
||||
prompt = tool_parameters.get('prompt', '')
|
||||
if not prompt:
|
||||
return self.create_text_message('Please input prompt')
|
||||
|
||||
seed = tool_parameters.get('seed', 0)
|
||||
if seed > 0:
|
||||
extra_body['seed'] = seed
|
||||
steps = tool_parameters.get('steps', 0)
|
||||
if steps > 0:
|
||||
extra_body['steps'] = steps
|
||||
negative_prompt = tool_parameters.get('negative_prompt', '')
|
||||
if negative_prompt:
|
||||
extra_body['negative_prompt'] = negative_prompt
|
||||
|
||||
# call openapi stepfun model
|
||||
response = client.images.generate(
|
||||
prompt=prompt,
|
||||
model=model,
|
||||
size=tool_parameters.get('size', '1024x1024'),
|
||||
n=tool_parameters.get('n', 1),
|
||||
extra_body= extra_body
|
||||
)
|
||||
print(response)
|
||||
|
||||
result = []
|
||||
for image in response.data:
|
||||
result.append(self.create_image_message(image=image.url))
|
||||
result.append(self.create_json_message({
|
||||
"url": image.url,
|
||||
}))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def _generate_random_id(length=8):
|
||||
characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
||||
random_id = ''.join(random.choices(characters, k=length))
|
||||
return random_id
|
158
api/core/tools/provider/builtin/stepfun/tools/image.yaml
Normal file
158
api/core/tools/provider/builtin/stepfun/tools/image.yaml
Normal file
|
@ -0,0 +1,158 @@
|
|||
identity:
|
||||
name: stepfun
|
||||
author: Stepfun
|
||||
label:
|
||||
en_US: step-1x
|
||||
zh_Hans: 阶跃星辰绘画
|
||||
pt_BR: step-1x
|
||||
description:
|
||||
en_US: step-1x is a powerful drawing tool by stepfun, you can draw the image based on your prompt
|
||||
zh_Hans: step-1x 系列是阶跃星辰提供的强大的绘画工具,它可以根据您的提示词绘制出您想要的图像。
|
||||
pt_BR: step-1x is a powerful drawing tool by stepfun, you can draw the image based on your prompt
|
||||
description:
|
||||
human:
|
||||
en_US: step-1x is a text to image tool
|
||||
zh_Hans: step-1x 是一个文本/图像到图像的工具
|
||||
pt_BR: step-1x is a text to image tool
|
||||
llm: step-1x is a tool used to generate images from text or image
|
||||
parameters:
|
||||
- name: prompt
|
||||
type: string
|
||||
required: true
|
||||
label:
|
||||
en_US: Prompt
|
||||
zh_Hans: 提示词
|
||||
pt_BR: Prompt
|
||||
human_description:
|
||||
en_US: Image prompt, you can check the official documentation of step-1x
|
||||
zh_Hans: 图像提示词,您可以查看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
|
||||
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
|
||||
type: select
|
||||
required: false
|
||||
human_description:
|
||||
en_US: used for selecting the image size
|
||||
zh_Hans: 用于选择图像大小
|
||||
pt_BR: used for selecting the image size
|
||||
label:
|
||||
en_US: Image size
|
||||
zh_Hans: 图像大小
|
||||
pt_BR: Image size
|
||||
form: form
|
||||
options:
|
||||
- value: 256x256
|
||||
label:
|
||||
en_US: 256x256
|
||||
zh_Hans: 256x256
|
||||
pt_BR: 256x256
|
||||
- value: 512x512
|
||||
label:
|
||||
en_US: 512x512
|
||||
zh_Hans: 512x512
|
||||
pt_BR: 512x512
|
||||
- value: 768x768
|
||||
label:
|
||||
en_US: 768x768
|
||||
zh_Hans: 768x768
|
||||
pt_BR: 768x768
|
||||
- value: 1024x1024
|
||||
label:
|
||||
en_US: 1024x1024
|
||||
zh_Hans: 1024x1024
|
||||
pt_BR: 1024x1024
|
||||
- value: 1280x800
|
||||
label:
|
||||
en_US: 1280x800
|
||||
zh_Hans: 1280x800
|
||||
pt_BR: 1280x800
|
||||
- value: 800x1280
|
||||
label:
|
||||
en_US: 800x1280
|
||||
zh_Hans: 800x1280
|
||||
pt_BR: 800x1280
|
||||
default: 1024x1024
|
||||
- name: n
|
||||
type: number
|
||||
required: true
|
||||
human_description:
|
||||
en_US: used for selecting the number of images
|
||||
zh_Hans: 用于选择图像数量
|
||||
pt_BR: used for selecting the number of images
|
||||
label:
|
||||
en_US: Number of images
|
||||
zh_Hans: 图像数量
|
||||
pt_BR: Number of images
|
||||
form: form
|
||||
default: 1
|
||||
min: 1
|
||||
max: 10
|
||||
- name: seed
|
||||
type: number
|
||||
required: false
|
||||
label:
|
||||
en_US: seed
|
||||
zh_Hans: seed
|
||||
pt_BR: seed
|
||||
human_description:
|
||||
en_US: seed
|
||||
zh_Hans: seed
|
||||
pt_BR: seed
|
||||
form: form
|
||||
default: 10
|
||||
- name: steps
|
||||
type: number
|
||||
required: false
|
||||
label:
|
||||
en_US: Steps
|
||||
zh_Hans: Steps
|
||||
pt_BR: Steps
|
||||
human_description:
|
||||
en_US: Steps
|
||||
zh_Hans: Steps
|
||||
pt_BR: Steps
|
||||
form: form
|
||||
default: 10
|
||||
- name: negative_prompt
|
||||
type: string
|
||||
required: false
|
||||
label:
|
||||
en_US: Negative prompt
|
||||
zh_Hans: Negative prompt
|
||||
pt_BR: Negative prompt
|
||||
human_description:
|
||||
en_US: Negative prompt
|
||||
zh_Hans: Negative prompt
|
||||
pt_BR: Negative prompt
|
||||
form: form
|
||||
default: (worst quality:1.3), (nsfw), low quality
|
Loading…
Reference in New Issue
Block a user