-
Notifications
You must be signed in to change notification settings - Fork 77
feat: add some new workflow apis #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tcsp
wants to merge
1
commit into
coze-dev:main
Choose a base branch
from
tcsp:feat/add_workflow_api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,31 @@ | ||
package com.coze.openapi.api; | ||
|
||
import com.coze.openapi.client.common.BaseReq; | ||
import com.coze.openapi.client.common.BaseResponse; | ||
import com.coze.openapi.client.workflows.WorkflowGetResp; | ||
import com.coze.openapi.client.workflows.WorkflowListResp; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Path; | ||
import retrofit2.http.Query; | ||
import retrofit2.http.Tag; | ||
|
||
public interface WorkflowAPI { | ||
|
||
@GET("/v1/workflows") | ||
Call<BaseResponse<WorkflowListResp>> list( | ||
@Query("workspace_id") String workspaceId, | ||
@Query("page_num") Integer pageNum, | ||
@Query("page_size") Integer pageSize, | ||
@Query("workflow_mode") String workflowMode, | ||
@Query("app_id") String appId, | ||
@Query("publish_status") String publishStatus, | ||
@Tag BaseReq baseReq); | ||
|
||
@GET("/v1/workflows/{workflow_id}") | ||
Call<BaseResponse<WorkflowGetResp>> get( | ||
@Path("workflow_id") String workflowId, | ||
@Query("include_input_output") Boolean includeInputOutput, | ||
@Tag BaseReq baseReq); | ||
} |
29 changes: 29 additions & 0 deletions
29
api/src/main/java/com/coze/openapi/client/workflows/WorkflowGetReq.java
This file contains hidden or 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,29 @@ | ||
package com.coze.openapi.client.workflows; | ||
|
||
import com.coze.openapi.client.common.BaseReq; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WorkflowGetReq extends BaseReq { | ||
|
||
/** 工作流 ID。 */ | ||
@NonNull | ||
@JsonProperty("workflow_id") | ||
private String workflowId; | ||
|
||
/** 是否在返回结果中返回输入和输出参数的结构体。 true:返回输入输出参数结构体 false:不返回输入输出参数结构体 默认值为 false。 */ | ||
@NonNull | ||
@JsonProperty("include_input_output") | ||
private Boolean includeInputOutput; | ||
} |
30 changes: 30 additions & 0 deletions
30
api/src/main/java/com/coze/openapi/client/workflows/WorkflowGetResp.java
This file contains hidden or 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,30 @@ | ||
package com.coze.openapi.client.workflows; | ||
|
||
import com.coze.openapi.client.workflows.model.WorkflowDetail; | ||
import com.coze.openapi.client.workflows.model.WorkflowInput; | ||
import com.coze.openapi.client.workflows.model.WorkflowOutput; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class WorkflowGetResp { | ||
|
||
/** 工作流开始节点的输入参数的结构体。 */ | ||
@JsonProperty("input") | ||
private WorkflowInput input; | ||
/** 工作流结束节点的输出参数的结构体。 */ | ||
@JsonProperty("output") | ||
private WorkflowOutput output; | ||
/** 工作流的详细信息。 */ | ||
@JsonProperty("workflow_detail") | ||
private WorkflowDetail workflowDetail; | ||
} |
44 changes: 44 additions & 0 deletions
44
api/src/main/java/com/coze/openapi/client/workflows/WorkflowListReq.java
This file contains hidden or 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,44 @@ | ||
package com.coze.openapi.client.workflows; | ||
|
||
import com.coze.openapi.client.common.BaseReq; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WorkflowListReq extends BaseReq { | ||
|
||
/** 工作空间 ID,用于指定要查询的工作空间。 */ | ||
@NonNull | ||
@JsonProperty("workspace_id") | ||
private String workspaceId; | ||
|
||
/** 查询结果分页展示时,此参数用于设置查看的页码。最小值为 1。 */ | ||
@NonNull | ||
@JsonProperty("page_num") | ||
private Integer pageNum; | ||
/** 查询结果分页展示时,此参数用于设置每页返回的数据量。取值范围为 1 ~ 30,默认为 10。 */ | ||
@JsonProperty("page_size") | ||
private Integer pageSize; | ||
/** 工作流类型,默认为空,即查询所有工作流类型。枚举值: workflow:工作流。 chatflow:对话流。 */ | ||
@JsonProperty("workflow_mode") | ||
private String workflowMode; | ||
/** 扣子应用 ID,用于查询指定应用关联的工作流。默认为空,即不指定应用。 */ | ||
@JsonProperty("app_id") | ||
private String appId; | ||
/** | ||
* 工作流的发布状态,用于筛选不同发布状态的工作流。枚举值: all :所有状态。 published_online :(默认值)已发布的正式版。 unpublished_draft | ||
* :当前为草稿状态。 | ||
*/ | ||
@JsonProperty("publish_status") | ||
private String publishStatus; | ||
} |
26 changes: 26 additions & 0 deletions
26
api/src/main/java/com/coze/openapi/client/workflows/WorkflowListResp.java
This file contains hidden or 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,26 @@ | ||
package com.coze.openapi.client.workflows; | ||
|
||
import java.util.List; | ||
|
||
import com.coze.openapi.client.workflows.model.WorkflowDetail; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class WorkflowListResp { | ||
/** 工作流的基础信息。 */ | ||
@JsonProperty("items") | ||
private List<WorkflowDetail> items; | ||
/** 标识当前返回的工作流列表是否还有更多数据未返回。 true :还有更多未返回的回调应用。 false:已返回所有数据。 */ | ||
@JsonProperty("has_more") | ||
private Boolean hasMore; | ||
} |
22 changes: 22 additions & 0 deletions
22
api/src/main/java/com/coze/openapi/client/workflows/model/WorkflowCreator.java
This file contains hidden or 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,22 @@ | ||
package com.coze.openapi.client.workflows.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WorkflowCreator { | ||
|
||
/** 工作流创建者的扣子用户 ID。 */ | ||
@JsonProperty("id") | ||
private String id; | ||
/** 工作流创建者的扣子用户名。 */ | ||
@JsonProperty("name") | ||
private String name; | ||
} |
40 changes: 40 additions & 0 deletions
40
api/src/main/java/com/coze/openapi/client/workflows/model/WorkflowDetail.java
This file contains hidden or 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,40 @@ | ||
package com.coze.openapi.client.workflows.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WorkflowDetail { | ||
|
||
/** 工作流关联的应用 ID。若工作流未关联任何应用,则该字段值为 0 */ | ||
@JsonProperty("app_id") | ||
private String app_id; | ||
/** 工作流创建者的信息,包含创建者的用户 ID 和用户名 */ | ||
@JsonProperty("creator") | ||
private WorkflowCreator creator; | ||
/** 工作流图标的 URL 地址。 */ | ||
@JsonProperty("icon_url") | ||
private String iconUrl; | ||
/** 工作流的创建时间,以 Unix 时间戳表示,单位为秒 */ | ||
@JsonProperty("created_at") | ||
private String createdAt; | ||
/** 工作流的最后更新时间,以 Unix 时间戳表示,单位为秒 */ | ||
@JsonProperty("updated_at") | ||
private String updatedAt; | ||
/** 工作流的描述。 */ | ||
@JsonProperty("description") | ||
private String description; | ||
/** 工作流 ID。 */ | ||
@JsonProperty("workflow_id") | ||
private String workflowId; | ||
/** 工作流名称。 */ | ||
@JsonProperty("workflow_name") | ||
private String workflowName; | ||
} |
21 changes: 21 additions & 0 deletions
21
api/src/main/java/com/coze/openapi/client/workflows/model/WorkflowInput.java
This file contains hidden or 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,21 @@ | ||
package com.coze.openapi.client.workflows.model; | ||
|
||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WorkflowInput { | ||
|
||
/** 开始节点的输入参数结构体。 */ | ||
@JsonProperty("parameters") | ||
private Map<String, WorkflowParameter> parameters; | ||
} |
27 changes: 27 additions & 0 deletions
27
api/src/main/java/com/coze/openapi/client/workflows/model/WorkflowOutput.java
This file contains hidden or 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,27 @@ | ||
package com.coze.openapi.client.workflows.model; | ||
|
||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WorkflowOutput { | ||
|
||
/** 工作流结束节点输出变量的数组。以键值对形式存储,格式为 { "变量名称": { "type": "变量类型" } }。 */ | ||
@JsonProperty("parameters") | ||
private Map<String, WorkflowParameter> parameters; | ||
/** 工作流结束节点返回文本时,智能体回复内容的结构。仅当 terminate_plan 为 use_answer_content 时会返回。 */ | ||
@JsonProperty("content") | ||
private String content; | ||
/** 结束节点的返回类型,枚举值: return_variables:返回变量。 use_answer_content:返回文本。 */ | ||
@JsonProperty("terminate_plan") | ||
private String terminatePlan; | ||
} |
36 changes: 36 additions & 0 deletions
36
api/src/main/java/com/coze/openapi/client/workflows/model/WorkflowParameter.java
This file contains hidden or 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,36 @@ | ||
package com.coze.openapi.client.workflows.model; | ||
|
||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WorkflowParameter { | ||
|
||
/** 该参数的类型。 */ | ||
@JsonProperty("type") | ||
private String type; | ||
/** 当参数类型为 array 时,该字段用于定义数组元素的子类型。 */ | ||
@JsonProperty("items") | ||
private WorkflowParameter items; | ||
/** 标识输入参数是否为必填项。 true:该参数为必填项。 false:该参数为可选项。 */ | ||
@JsonProperty("required") | ||
private Boolean required; | ||
/** 当参数类型为 object 时,该字段用于定义数组元素的子类型。 */ | ||
@JsonProperty("properties") | ||
private Map<String, WorkflowParameter> properties; | ||
/** 该参数的描述信息。 */ | ||
@JsonProperty("description") | ||
private String description; | ||
/** 该参数配置的默认值。 */ | ||
@JsonProperty("default_value") | ||
private String defaultValue; | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix Javadoc: “回调应用” → “工作流”.
Current description is misleading in generated docs.
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个应该不用改吧,是官方文档的备注
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@tcsp 经过查证,我理解您的观点。如果这个描述确实来自于官方文档,那么保持与官方文档一致是合理的做法。我的建议可能过于武断了。
不过,如果您有时间的话,建议您可以向官方反馈这个术语的一致性问题 - 在工作流相关的API文档中使用"回调应用"这个术语可能会让开发者产生困惑,因为我们讨论的是工作流(workflows),而不是回调应用(callback applications)。
但您说得对,如果这是官方文档的原文,那么现在保持一致是正确的选择。
🏁 Script executed:
Length of output: 725
@tcsp 您说得对,保持与官方文档的一致性确实更重要。通过搜索确认这是代码库中唯一出现"回调应用"的地方,既然这是官方文档的原文,那么保持原样是正确的做法。
感谢您的澄清!
✏️ Learnings added