feat: Support for Chat Flow & Agent Support for binding a single chat flow (#765)
Co-authored-by: Yu Yang <72337138+tomasyu985@users.noreply.github.com> Co-authored-by: zengxiaohui <csu.zengxiaohui@gmail.com> Co-authored-by: lijunwen.gigoo <lijunwen.gigoo@bytedance.com> Co-authored-by: lvxinyu.1117 <lvxinyu.1117@bytedance.com> Co-authored-by: liuyunchao.0510 <liuyunchao.0510@bytedance.com> Co-authored-by: haozhenfei <37089575+haozhenfei@users.noreply.github.com> Co-authored-by: July <jiangxujin@bytedance.com> Co-authored-by: tecvan-fe <fanwenjie.fe@bytedance.com>
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by thriftgo (0.4.1). DO NOT EDIT.
|
||||
|
||||
package agentrun
|
||||
@@ -5,6 +21,7 @@ package agentrun
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||
)
|
||||
@@ -13,6 +30,8 @@ type AgentRunService interface {
|
||||
AgentRun(ctx context.Context, request *run.AgentRunRequest) (r *run.AgentRunResponse, err error)
|
||||
|
||||
ChatV3(ctx context.Context, request *run.ChatV3Request) (r *run.ChatV3Response, err error)
|
||||
|
||||
CancelChatApi(ctx context.Context, request *run.CancelChatApiRequest) (r *run.CancelChatApiResponse, err error)
|
||||
}
|
||||
|
||||
type AgentRunServiceClient struct {
|
||||
@@ -59,6 +78,15 @@ func (p *AgentRunServiceClient) ChatV3(ctx context.Context, request *run.ChatV3R
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
func (p *AgentRunServiceClient) CancelChatApi(ctx context.Context, request *run.CancelChatApiRequest) (r *run.CancelChatApiResponse, err error) {
|
||||
var _args AgentRunServiceCancelChatApiArgs
|
||||
_args.Request = request
|
||||
var _result AgentRunServiceCancelChatApiResult
|
||||
if err = p.Client_().Call(ctx, "CancelChatApi", &_args, &_result); err != nil {
|
||||
return
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
|
||||
type AgentRunServiceProcessor struct {
|
||||
processorMap map[string]thrift.TProcessorFunction
|
||||
@@ -82,6 +110,7 @@ func NewAgentRunServiceProcessor(handler AgentRunService) *AgentRunServiceProces
|
||||
self := &AgentRunServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
|
||||
self.AddToProcessorMap("AgentRun", &agentRunServiceProcessorAgentRun{handler: handler})
|
||||
self.AddToProcessorMap("ChatV3", &agentRunServiceProcessorChatV3{handler: handler})
|
||||
self.AddToProcessorMap("CancelChatApi", &agentRunServiceProcessorCancelChatApi{handler: handler})
|
||||
return self
|
||||
}
|
||||
func (p *AgentRunServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
@@ -198,6 +227,54 @@ func (p *agentRunServiceProcessorChatV3) Process(ctx context.Context, seqId int3
|
||||
return true, err
|
||||
}
|
||||
|
||||
type agentRunServiceProcessorCancelChatApi struct {
|
||||
handler AgentRunService
|
||||
}
|
||||
|
||||
func (p *agentRunServiceProcessorCancelChatApi) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
args := AgentRunServiceCancelChatApiArgs{}
|
||||
if err = args.Read(iprot); err != nil {
|
||||
iprot.ReadMessageEnd()
|
||||
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
|
||||
oprot.WriteMessageBegin("CancelChatApi", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return false, err
|
||||
}
|
||||
|
||||
iprot.ReadMessageEnd()
|
||||
var err2 error
|
||||
result := AgentRunServiceCancelChatApiResult{}
|
||||
var retval *run.CancelChatApiResponse
|
||||
if retval, err2 = p.handler.CancelChatApi(ctx, args.Request); err2 != nil {
|
||||
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing CancelChatApi: "+err2.Error())
|
||||
oprot.WriteMessageBegin("CancelChatApi", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return true, err2
|
||||
} else {
|
||||
result.Success = retval
|
||||
}
|
||||
if err2 = oprot.WriteMessageBegin("CancelChatApi", thrift.REPLY, seqId); err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
if err2 = result.Write(oprot); err == nil && err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return true, err
|
||||
}
|
||||
|
||||
type AgentRunServiceAgentRunArgs struct {
|
||||
Request *run.AgentRunRequest `thrift:"request,1"`
|
||||
}
|
||||
@@ -781,3 +858,295 @@ func (p *AgentRunServiceChatV3Result) String() string {
|
||||
return fmt.Sprintf("AgentRunServiceChatV3Result(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type AgentRunServiceCancelChatApiArgs struct {
|
||||
Request *run.CancelChatApiRequest `thrift:"request,1"`
|
||||
}
|
||||
|
||||
func NewAgentRunServiceCancelChatApiArgs() *AgentRunServiceCancelChatApiArgs {
|
||||
return &AgentRunServiceCancelChatApiArgs{}
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) InitDefault() {
|
||||
}
|
||||
|
||||
var AgentRunServiceCancelChatApiArgs_Request_DEFAULT *run.CancelChatApiRequest
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) GetRequest() (v *run.CancelChatApiRequest) {
|
||||
if !p.IsSetRequest() {
|
||||
return AgentRunServiceCancelChatApiArgs_Request_DEFAULT
|
||||
}
|
||||
return p.Request
|
||||
}
|
||||
|
||||
var fieldIDToName_AgentRunServiceCancelChatApiArgs = map[int16]string{
|
||||
1: "request",
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) IsSetRequest() bool {
|
||||
return p.Request != nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.STRUCT {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AgentRunServiceCancelChatApiArgs[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) ReadField1(iprot thrift.TProtocol) error {
|
||||
_field := run.NewCancelChatApiRequest()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Request = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("CancelChatApi_args"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.Request.Write(oprot); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiArgs) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("AgentRunServiceCancelChatApiArgs(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type AgentRunServiceCancelChatApiResult struct {
|
||||
Success *run.CancelChatApiResponse `thrift:"success,0,optional"`
|
||||
}
|
||||
|
||||
func NewAgentRunServiceCancelChatApiResult() *AgentRunServiceCancelChatApiResult {
|
||||
return &AgentRunServiceCancelChatApiResult{}
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) InitDefault() {
|
||||
}
|
||||
|
||||
var AgentRunServiceCancelChatApiResult_Success_DEFAULT *run.CancelChatApiResponse
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) GetSuccess() (v *run.CancelChatApiResponse) {
|
||||
if !p.IsSetSuccess() {
|
||||
return AgentRunServiceCancelChatApiResult_Success_DEFAULT
|
||||
}
|
||||
return p.Success
|
||||
}
|
||||
|
||||
var fieldIDToName_AgentRunServiceCancelChatApiResult = map[int16]string{
|
||||
0: "success",
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) IsSetSuccess() bool {
|
||||
return p.Success != nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
|
||||
if _, err = iprot.ReadStructBegin(); err != nil {
|
||||
goto ReadStructBeginError
|
||||
}
|
||||
|
||||
for {
|
||||
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
|
||||
if err != nil {
|
||||
goto ReadFieldBeginError
|
||||
}
|
||||
if fieldTypeId == thrift.STOP {
|
||||
break
|
||||
}
|
||||
|
||||
switch fieldId {
|
||||
case 0:
|
||||
if fieldTypeId == thrift.STRUCT {
|
||||
if err = p.ReadField0(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
default:
|
||||
if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadFieldEnd(); err != nil {
|
||||
goto ReadFieldEndError
|
||||
}
|
||||
}
|
||||
if err = iprot.ReadStructEnd(); err != nil {
|
||||
goto ReadStructEndError
|
||||
}
|
||||
|
||||
return nil
|
||||
ReadStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||
ReadFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||
ReadFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AgentRunServiceCancelChatApiResult[fieldId]), err)
|
||||
SkipFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||
|
||||
ReadFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||
ReadStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) ReadField0(iprot thrift.TProtocol) error {
|
||||
_field := run.NewCancelChatApiResponse()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Success = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("CancelChatApi_result"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField0(oprot); err != nil {
|
||||
fieldId = 0
|
||||
goto WriteFieldError
|
||||
}
|
||||
}
|
||||
if err = oprot.WriteFieldStop(); err != nil {
|
||||
goto WriteFieldStopError
|
||||
}
|
||||
if err = oprot.WriteStructEnd(); err != nil {
|
||||
goto WriteStructEndError
|
||||
}
|
||||
return nil
|
||||
WriteStructBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
||||
WriteFieldError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
|
||||
WriteFieldStopError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
|
||||
WriteStructEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) writeField0(oprot thrift.TProtocol) (err error) {
|
||||
if p.IsSetSuccess() {
|
||||
if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.Success.Write(oprot); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceCancelChatApiResult) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("AgentRunServiceCancelChatApiResult(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user