feat: support openapi chat with non-stream (#2431)
This commit is contained in:
@ -108,6 +108,18 @@ func ChatV3(ctx context.Context, c *app.RequestContext) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.Stream != nil && !*req.Stream {
|
||||
|
||||
resp, err := conversation.ConversationOpenAPISVC.OpenapiAgentRunSync(ctx, &req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// Streaming mode (default)
|
||||
c.SetStatusCode(http.StatusOK)
|
||||
c.Response.Header.Set("X-Accel-Buffering", "no")
|
||||
sseSender := sseImpl.NewSSESender(sse.NewStream(c))
|
||||
@ -195,3 +207,23 @@ func preprocessChatV3Parameters(c *app.RequestContext) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RetrieveChatOpen .
|
||||
// @router /v3/chat/retrieve [GET]
|
||||
func RetrieveChatOpen(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req run.RetrieveChatOpenRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := conversation.ConversationOpenAPISVC.RetrieveRunRecord(ctx, &req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
@ -148,3 +148,23 @@ func GetApiMessageList(ctx context.Context, c *app.RequestContext) {
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListChatMessageApi .
|
||||
// @router /v3/chat/message/list [GET]
|
||||
func ListChatMessageApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req message.ListChatMessageApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationOpenAPISVC.ListChatMessageApi(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
@ -52,6 +52,8 @@ var needAuthPath = map[string]bool{
|
||||
"/v1/workflow/conversation/create": true,
|
||||
"/v3/chat/cancel": true,
|
||||
"/v1/conversation/retrieve": true,
|
||||
"/v3/chat/retrieve": true,
|
||||
"/v3/chat/message/list": true,
|
||||
}
|
||||
|
||||
var needAuthFunc = map[string]bool{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
// Code generated by thriftgo (0.4.1). DO NOT EDIT.
|
||||
|
||||
package agentrun
|
||||
|
||||
@ -15,6 +15,8 @@ type AgentRunService interface {
|
||||
ChatV3(ctx context.Context, request *run.ChatV3Request) (r *run.ChatV3Response, err error)
|
||||
|
||||
CancelChatApi(ctx context.Context, request *run.CancelChatApiRequest) (r *run.CancelChatApiResponse, err error)
|
||||
|
||||
RetrieveChatOpen(ctx context.Context, request *run.RetrieveChatOpenRequest) (r *run.RetrieveChatOpenResponse, err error)
|
||||
}
|
||||
|
||||
type AgentRunServiceClient struct {
|
||||
@ -70,6 +72,15 @@ func (p *AgentRunServiceClient) CancelChatApi(ctx context.Context, request *run.
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
func (p *AgentRunServiceClient) RetrieveChatOpen(ctx context.Context, request *run.RetrieveChatOpenRequest) (r *run.RetrieveChatOpenResponse, err error) {
|
||||
var _args AgentRunServiceRetrieveChatOpenArgs
|
||||
_args.Request = request
|
||||
var _result AgentRunServiceRetrieveChatOpenResult
|
||||
if err = p.Client_().Call(ctx, "RetrieveChatOpen", &_args, &_result); err != nil {
|
||||
return
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
|
||||
type AgentRunServiceProcessor struct {
|
||||
processorMap map[string]thrift.TProcessorFunction
|
||||
@ -94,6 +105,7 @@ func NewAgentRunServiceProcessor(handler AgentRunService) *AgentRunServiceProces
|
||||
self.AddToProcessorMap("AgentRun", &agentRunServiceProcessorAgentRun{handler: handler})
|
||||
self.AddToProcessorMap("ChatV3", &agentRunServiceProcessorChatV3{handler: handler})
|
||||
self.AddToProcessorMap("CancelChatApi", &agentRunServiceProcessorCancelChatApi{handler: handler})
|
||||
self.AddToProcessorMap("RetrieveChatOpen", &agentRunServiceProcessorRetrieveChatOpen{handler: handler})
|
||||
return self
|
||||
}
|
||||
func (p *AgentRunServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
@ -258,6 +270,54 @@ func (p *agentRunServiceProcessorCancelChatApi) Process(ctx context.Context, seq
|
||||
return true, err
|
||||
}
|
||||
|
||||
type agentRunServiceProcessorRetrieveChatOpen struct {
|
||||
handler AgentRunService
|
||||
}
|
||||
|
||||
func (p *agentRunServiceProcessorRetrieveChatOpen) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
args := AgentRunServiceRetrieveChatOpenArgs{}
|
||||
if err = args.Read(iprot); err != nil {
|
||||
iprot.ReadMessageEnd()
|
||||
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
|
||||
oprot.WriteMessageBegin("RetrieveChatOpen", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return false, err
|
||||
}
|
||||
|
||||
iprot.ReadMessageEnd()
|
||||
var err2 error
|
||||
result := AgentRunServiceRetrieveChatOpenResult{}
|
||||
var retval *run.RetrieveChatOpenResponse
|
||||
if retval, err2 = p.handler.RetrieveChatOpen(ctx, args.Request); err2 != nil {
|
||||
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing RetrieveChatOpen: "+err2.Error())
|
||||
oprot.WriteMessageBegin("RetrieveChatOpen", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return true, err2
|
||||
} else {
|
||||
result.Success = retval
|
||||
}
|
||||
if err2 = oprot.WriteMessageBegin("RetrieveChatOpen", 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"`
|
||||
}
|
||||
@ -1133,3 +1193,295 @@ func (p *AgentRunServiceCancelChatApiResult) String() string {
|
||||
return fmt.Sprintf("AgentRunServiceCancelChatApiResult(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type AgentRunServiceRetrieveChatOpenArgs struct {
|
||||
Request *run.RetrieveChatOpenRequest `thrift:"request,1"`
|
||||
}
|
||||
|
||||
func NewAgentRunServiceRetrieveChatOpenArgs() *AgentRunServiceRetrieveChatOpenArgs {
|
||||
return &AgentRunServiceRetrieveChatOpenArgs{}
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenArgs) InitDefault() {
|
||||
}
|
||||
|
||||
var AgentRunServiceRetrieveChatOpenArgs_Request_DEFAULT *run.RetrieveChatOpenRequest
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenArgs) GetRequest() (v *run.RetrieveChatOpenRequest) {
|
||||
if !p.IsSetRequest() {
|
||||
return AgentRunServiceRetrieveChatOpenArgs_Request_DEFAULT
|
||||
}
|
||||
return p.Request
|
||||
}
|
||||
|
||||
var fieldIDToName_AgentRunServiceRetrieveChatOpenArgs = map[int16]string{
|
||||
1: "request",
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenArgs) IsSetRequest() bool {
|
||||
return p.Request != nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenArgs) 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_AgentRunServiceRetrieveChatOpenArgs[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 *AgentRunServiceRetrieveChatOpenArgs) ReadField1(iprot thrift.TProtocol) error {
|
||||
_field := run.NewRetrieveChatOpenRequest()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Request = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenArgs) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveChatOpen_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 *AgentRunServiceRetrieveChatOpenArgs) 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 *AgentRunServiceRetrieveChatOpenArgs) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("AgentRunServiceRetrieveChatOpenArgs(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type AgentRunServiceRetrieveChatOpenResult struct {
|
||||
Success *run.RetrieveChatOpenResponse `thrift:"success,0,optional"`
|
||||
}
|
||||
|
||||
func NewAgentRunServiceRetrieveChatOpenResult() *AgentRunServiceRetrieveChatOpenResult {
|
||||
return &AgentRunServiceRetrieveChatOpenResult{}
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenResult) InitDefault() {
|
||||
}
|
||||
|
||||
var AgentRunServiceRetrieveChatOpenResult_Success_DEFAULT *run.RetrieveChatOpenResponse
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenResult) GetSuccess() (v *run.RetrieveChatOpenResponse) {
|
||||
if !p.IsSetSuccess() {
|
||||
return AgentRunServiceRetrieveChatOpenResult_Success_DEFAULT
|
||||
}
|
||||
return p.Success
|
||||
}
|
||||
|
||||
var fieldIDToName_AgentRunServiceRetrieveChatOpenResult = map[int16]string{
|
||||
0: "success",
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenResult) IsSetSuccess() bool {
|
||||
return p.Success != nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenResult) 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_AgentRunServiceRetrieveChatOpenResult[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 *AgentRunServiceRetrieveChatOpenResult) ReadField0(iprot thrift.TProtocol) error {
|
||||
_field := run.NewRetrieveChatOpenResponse()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Success = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *AgentRunServiceRetrieveChatOpenResult) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveChatOpen_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 *AgentRunServiceRetrieveChatOpenResult) 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 *AgentRunServiceRetrieveChatOpenResult) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("AgentRunServiceRetrieveChatOpenResult(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
// Code generated by thriftgo (0.4.1). DO NOT EDIT.
|
||||
|
||||
package message
|
||||
|
||||
@ -16,6 +16,8 @@ type MessageService interface {
|
||||
BreakMessage(ctx context.Context, request *BreakMessageRequest) (r *BreakMessageResponse, err error)
|
||||
|
||||
GetApiMessageList(ctx context.Context, request *ListMessageApiRequest) (r *ListMessageApiResponse, err error)
|
||||
|
||||
ListChatMessageApi(ctx context.Context, request *ListChatMessageApiRequest) (r *ListChatMessageApiResponse, err error)
|
||||
}
|
||||
|
||||
type MessageServiceClient struct {
|
||||
@ -80,6 +82,15 @@ func (p *MessageServiceClient) GetApiMessageList(ctx context.Context, request *L
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
func (p *MessageServiceClient) ListChatMessageApi(ctx context.Context, request *ListChatMessageApiRequest) (r *ListChatMessageApiResponse, err error) {
|
||||
var _args MessageServiceListChatMessageApiArgs
|
||||
_args.Request = request
|
||||
var _result MessageServiceListChatMessageApiResult
|
||||
if err = p.Client_().Call(ctx, "ListChatMessageApi", &_args, &_result); err != nil {
|
||||
return
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
|
||||
type MessageServiceProcessor struct {
|
||||
processorMap map[string]thrift.TProcessorFunction
|
||||
@ -105,6 +116,7 @@ func NewMessageServiceProcessor(handler MessageService) *MessageServiceProcessor
|
||||
self.AddToProcessorMap("DeleteMessage", &messageServiceProcessorDeleteMessage{handler: handler})
|
||||
self.AddToProcessorMap("BreakMessage", &messageServiceProcessorBreakMessage{handler: handler})
|
||||
self.AddToProcessorMap("GetApiMessageList", &messageServiceProcessorGetApiMessageList{handler: handler})
|
||||
self.AddToProcessorMap("ListChatMessageApi", &messageServiceProcessorListChatMessageApi{handler: handler})
|
||||
return self
|
||||
}
|
||||
func (p *MessageServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
@ -317,6 +329,54 @@ func (p *messageServiceProcessorGetApiMessageList) Process(ctx context.Context,
|
||||
return true, err
|
||||
}
|
||||
|
||||
type messageServiceProcessorListChatMessageApi struct {
|
||||
handler MessageService
|
||||
}
|
||||
|
||||
func (p *messageServiceProcessorListChatMessageApi) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
args := MessageServiceListChatMessageApiArgs{}
|
||||
if err = args.Read(iprot); err != nil {
|
||||
iprot.ReadMessageEnd()
|
||||
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
|
||||
oprot.WriteMessageBegin("ListChatMessageApi", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return false, err
|
||||
}
|
||||
|
||||
iprot.ReadMessageEnd()
|
||||
var err2 error
|
||||
result := MessageServiceListChatMessageApiResult{}
|
||||
var retval *ListChatMessageApiResponse
|
||||
if retval, err2 = p.handler.ListChatMessageApi(ctx, args.Request); err2 != nil {
|
||||
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ListChatMessageApi: "+err2.Error())
|
||||
oprot.WriteMessageBegin("ListChatMessageApi", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return true, err2
|
||||
} else {
|
||||
result.Success = retval
|
||||
}
|
||||
if err2 = oprot.WriteMessageBegin("ListChatMessageApi", 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 MessageServiceGetMessageListArgs struct {
|
||||
Request *GetMessageListRequest `thrift:"request,1"`
|
||||
}
|
||||
@ -1484,3 +1544,295 @@ func (p *MessageServiceGetApiMessageListResult) String() string {
|
||||
return fmt.Sprintf("MessageServiceGetApiMessageListResult(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type MessageServiceListChatMessageApiArgs struct {
|
||||
Request *ListChatMessageApiRequest `thrift:"request,1"`
|
||||
}
|
||||
|
||||
func NewMessageServiceListChatMessageApiArgs() *MessageServiceListChatMessageApiArgs {
|
||||
return &MessageServiceListChatMessageApiArgs{}
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiArgs) InitDefault() {
|
||||
}
|
||||
|
||||
var MessageServiceListChatMessageApiArgs_Request_DEFAULT *ListChatMessageApiRequest
|
||||
|
||||
func (p *MessageServiceListChatMessageApiArgs) GetRequest() (v *ListChatMessageApiRequest) {
|
||||
if !p.IsSetRequest() {
|
||||
return MessageServiceListChatMessageApiArgs_Request_DEFAULT
|
||||
}
|
||||
return p.Request
|
||||
}
|
||||
|
||||
var fieldIDToName_MessageServiceListChatMessageApiArgs = map[int16]string{
|
||||
1: "request",
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiArgs) IsSetRequest() bool {
|
||||
return p.Request != nil
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiArgs) 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_MessageServiceListChatMessageApiArgs[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 *MessageServiceListChatMessageApiArgs) ReadField1(iprot thrift.TProtocol) error {
|
||||
_field := NewListChatMessageApiRequest()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Request = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiArgs) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("ListChatMessageApi_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 *MessageServiceListChatMessageApiArgs) 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 *MessageServiceListChatMessageApiArgs) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("MessageServiceListChatMessageApiArgs(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type MessageServiceListChatMessageApiResult struct {
|
||||
Success *ListChatMessageApiResponse `thrift:"success,0,optional"`
|
||||
}
|
||||
|
||||
func NewMessageServiceListChatMessageApiResult() *MessageServiceListChatMessageApiResult {
|
||||
return &MessageServiceListChatMessageApiResult{}
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiResult) InitDefault() {
|
||||
}
|
||||
|
||||
var MessageServiceListChatMessageApiResult_Success_DEFAULT *ListChatMessageApiResponse
|
||||
|
||||
func (p *MessageServiceListChatMessageApiResult) GetSuccess() (v *ListChatMessageApiResponse) {
|
||||
if !p.IsSetSuccess() {
|
||||
return MessageServiceListChatMessageApiResult_Success_DEFAULT
|
||||
}
|
||||
return p.Success
|
||||
}
|
||||
|
||||
var fieldIDToName_MessageServiceListChatMessageApiResult = map[int16]string{
|
||||
0: "success",
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiResult) IsSetSuccess() bool {
|
||||
return p.Success != nil
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiResult) 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_MessageServiceListChatMessageApiResult[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 *MessageServiceListChatMessageApiResult) ReadField0(iprot thrift.TProtocol) error {
|
||||
_field := NewListChatMessageApiResponse()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Success = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *MessageServiceListChatMessageApiResult) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("ListChatMessageApi_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 *MessageServiceListChatMessageApiResult) 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 *MessageServiceListChatMessageApiResult) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("MessageServiceListChatMessageApiResult(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by thriftgo (0.4.2). DO NOT EDIT.
|
||||
// Code generated by thriftgo (0.4.1). DO NOT EDIT.
|
||||
|
||||
package run
|
||||
|
||||
@ -10130,3 +10130,556 @@ func (p *CancelChatApiResponse) String() string {
|
||||
return fmt.Sprintf("CancelChatApiResponse(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type RetrieveChatOpenRequest struct {
|
||||
ConversationID int64 `thrift:"ConversationID,1,required" json:"ConversationID,string,required" query:"conversation_id,required"`
|
||||
ChatID int64 `thrift:"ChatID,2,required" json:"ChatID,string,required" query:"chat_id,required"`
|
||||
Base *base.Base `thrift:"Base,255" form:"Base" json:"Base" query:"Base"`
|
||||
}
|
||||
|
||||
func NewRetrieveChatOpenRequest() *RetrieveChatOpenRequest {
|
||||
return &RetrieveChatOpenRequest{}
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) InitDefault() {
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) GetConversationID() (v int64) {
|
||||
return p.ConversationID
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) GetChatID() (v int64) {
|
||||
return p.ChatID
|
||||
}
|
||||
|
||||
var RetrieveChatOpenRequest_Base_DEFAULT *base.Base
|
||||
|
||||
func (p *RetrieveChatOpenRequest) GetBase() (v *base.Base) {
|
||||
if !p.IsSetBase() {
|
||||
return RetrieveChatOpenRequest_Base_DEFAULT
|
||||
}
|
||||
return p.Base
|
||||
}
|
||||
|
||||
var fieldIDToName_RetrieveChatOpenRequest = map[int16]string{
|
||||
1: "ConversationID",
|
||||
2: "ChatID",
|
||||
255: "Base",
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) IsSetBase() bool {
|
||||
return p.Base != nil
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
var issetConversationID bool = false
|
||||
var issetChatID bool = false
|
||||
|
||||
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.I64 {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
issetConversationID = true
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 2:
|
||||
if fieldTypeId == thrift.I64 {
|
||||
if err = p.ReadField2(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
issetChatID = true
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 255:
|
||||
if fieldTypeId == thrift.STRUCT {
|
||||
if err = p.ReadField255(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
|
||||
}
|
||||
|
||||
if !issetConversationID {
|
||||
fieldId = 1
|
||||
goto RequiredFieldNotSetError
|
||||
}
|
||||
|
||||
if !issetChatID {
|
||||
fieldId = 2
|
||||
goto RequiredFieldNotSetError
|
||||
}
|
||||
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_RetrieveChatOpenRequest[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)
|
||||
RequiredFieldNotSetError:
|
||||
return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_RetrieveChatOpenRequest[fieldId]))
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) ReadField1(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.ConversationID = _field
|
||||
return nil
|
||||
}
|
||||
func (p *RetrieveChatOpenRequest) ReadField2(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int64
|
||||
if v, err := iprot.ReadI64(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.ChatID = _field
|
||||
return nil
|
||||
}
|
||||
func (p *RetrieveChatOpenRequest) ReadField255(iprot thrift.TProtocol) error {
|
||||
_field := base.NewBase()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Base = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveChatOpenRequest"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField2(oprot); err != nil {
|
||||
fieldId = 2
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField255(oprot); err != nil {
|
||||
fieldId = 255
|
||||
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 *RetrieveChatOpenRequest) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("ConversationID", thrift.I64, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.ConversationID); 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 *RetrieveChatOpenRequest) writeField2(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("ChatID", thrift.I64, 2); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI64(p.ChatID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
|
||||
}
|
||||
func (p *RetrieveChatOpenRequest) writeField255(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.Base.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 255 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenRequest) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("RetrieveChatOpenRequest(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type RetrieveChatOpenResponse struct {
|
||||
ChatDetail *ChatV3ChatDetail `thrift:"ChatDetail,1,optional" form:"data" json:"data,omitempty"`
|
||||
Code int32 `thrift:"Code,253,required" form:"code,required" json:"code,required"`
|
||||
Msg string `thrift:"Msg,254,required" form:"msg,required" json:"msg,required"`
|
||||
BaseResp *base.BaseResp `thrift:"BaseResp,255" form:"BaseResp" json:"BaseResp" query:"BaseResp"`
|
||||
}
|
||||
|
||||
func NewRetrieveChatOpenResponse() *RetrieveChatOpenResponse {
|
||||
return &RetrieveChatOpenResponse{}
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) InitDefault() {
|
||||
}
|
||||
|
||||
var RetrieveChatOpenResponse_ChatDetail_DEFAULT *ChatV3ChatDetail
|
||||
|
||||
func (p *RetrieveChatOpenResponse) GetChatDetail() (v *ChatV3ChatDetail) {
|
||||
if !p.IsSetChatDetail() {
|
||||
return RetrieveChatOpenResponse_ChatDetail_DEFAULT
|
||||
}
|
||||
return p.ChatDetail
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) GetCode() (v int32) {
|
||||
return p.Code
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) GetMsg() (v string) {
|
||||
return p.Msg
|
||||
}
|
||||
|
||||
var RetrieveChatOpenResponse_BaseResp_DEFAULT *base.BaseResp
|
||||
|
||||
func (p *RetrieveChatOpenResponse) GetBaseResp() (v *base.BaseResp) {
|
||||
if !p.IsSetBaseResp() {
|
||||
return RetrieveChatOpenResponse_BaseResp_DEFAULT
|
||||
}
|
||||
return p.BaseResp
|
||||
}
|
||||
|
||||
var fieldIDToName_RetrieveChatOpenResponse = map[int16]string{
|
||||
1: "ChatDetail",
|
||||
253: "Code",
|
||||
254: "Msg",
|
||||
255: "BaseResp",
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) IsSetChatDetail() bool {
|
||||
return p.ChatDetail != nil
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) IsSetBaseResp() bool {
|
||||
return p.BaseResp != nil
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
var issetCode bool = false
|
||||
var issetMsg bool = false
|
||||
|
||||
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
|
||||
}
|
||||
case 253:
|
||||
if fieldTypeId == thrift.I32 {
|
||||
if err = p.ReadField253(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
issetCode = true
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 254:
|
||||
if fieldTypeId == thrift.STRING {
|
||||
if err = p.ReadField254(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
issetMsg = true
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
case 255:
|
||||
if fieldTypeId == thrift.STRUCT {
|
||||
if err = p.ReadField255(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
|
||||
}
|
||||
|
||||
if !issetCode {
|
||||
fieldId = 253
|
||||
goto RequiredFieldNotSetError
|
||||
}
|
||||
|
||||
if !issetMsg {
|
||||
fieldId = 254
|
||||
goto RequiredFieldNotSetError
|
||||
}
|
||||
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_RetrieveChatOpenResponse[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)
|
||||
RequiredFieldNotSetError:
|
||||
return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_RetrieveChatOpenResponse[fieldId]))
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) ReadField1(iprot thrift.TProtocol) error {
|
||||
_field := NewChatV3ChatDetail()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.ChatDetail = _field
|
||||
return nil
|
||||
}
|
||||
func (p *RetrieveChatOpenResponse) ReadField253(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field int32
|
||||
if v, err := iprot.ReadI32(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Code = _field
|
||||
return nil
|
||||
}
|
||||
func (p *RetrieveChatOpenResponse) ReadField254(iprot thrift.TProtocol) error {
|
||||
|
||||
var _field string
|
||||
if v, err := iprot.ReadString(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
_field = v
|
||||
}
|
||||
p.Msg = _field
|
||||
return nil
|
||||
}
|
||||
func (p *RetrieveChatOpenResponse) ReadField255(iprot thrift.TProtocol) error {
|
||||
_field := base.NewBaseResp()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.BaseResp = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveChatOpenResponse"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField253(oprot); err != nil {
|
||||
fieldId = 253
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField254(oprot); err != nil {
|
||||
fieldId = 254
|
||||
goto WriteFieldError
|
||||
}
|
||||
if err = p.writeField255(oprot); err != nil {
|
||||
fieldId = 255
|
||||
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 *RetrieveChatOpenResponse) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if p.IsSetChatDetail() {
|
||||
if err = oprot.WriteFieldBegin("ChatDetail", thrift.STRUCT, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.ChatDetail.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 *RetrieveChatOpenResponse) writeField253(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("Code", thrift.I32, 253); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteI32(p.Code); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 253 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 253 end error: ", p), err)
|
||||
}
|
||||
func (p *RetrieveChatOpenResponse) writeField254(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 254); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := oprot.WriteString(p.Msg); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
goto WriteFieldEndError
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 254 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 254 end error: ", p), err)
|
||||
}
|
||||
func (p *RetrieveChatOpenResponse) writeField255(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.BaseResp.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 255 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err)
|
||||
}
|
||||
|
||||
func (p *RetrieveChatOpenResponse) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("RetrieveChatOpenResponse(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
@ -501,5 +501,13 @@ func Register(r *server.Hertz) {
|
||||
_v3.POST("/chat", append(_chatv3Mw(), coze.ChatV3)...)
|
||||
_chat := _v3.Group("/chat", _chatMw()...)
|
||||
_chat.POST("/cancel", append(_cancelchatapiMw(), coze.CancelChatApi)...)
|
||||
_chat.GET("/retrieve", append(_retrievechatopenMw(), coze.RetrieveChatOpen)...)
|
||||
{
|
||||
_chat0 := _v3.Group("/chat", _chat0Mw()...)
|
||||
{
|
||||
_message0 := _chat0.Group("/message", _message0Mw()...)
|
||||
_message0.GET("/list", append(_listchatmessageapiMw(), coze.ListChatMessageApi)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1639,3 +1639,23 @@ func _retrieveconversationapiMw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
func _retrievechatopenMw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
func _chat0Mw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
func _message0Mw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
func _listchatmessageapiMw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -28,11 +28,12 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
singleagent "github.com/coze-dev/coze-studio/backend/crossdomain/agent/model"
|
||||
agentrun "github.com/coze-dev/coze-studio/backend/crossdomain/agentrun/model"
|
||||
message "github.com/coze-dev/coze-studio/backend/crossdomain/message/model"
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/message/model"
|
||||
saEntity "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
convEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
@ -228,10 +229,10 @@ func (a *OpenapiAgentRunApplication) buildDisplayContent(_ context.Context, ar *
|
||||
return ""
|
||||
}
|
||||
|
||||
func (a *OpenapiAgentRunApplication) parseQueryContent(ctx context.Context, multiAdditionalMessages []*entity.AdditionalMessage) ([]*entity.AdditionalMessage, []*message.InputMetaData, message.ContentType, error) {
|
||||
func (a *OpenapiAgentRunApplication) parseQueryContent(ctx context.Context, multiAdditionalMessages []*entity.AdditionalMessage) ([]*entity.AdditionalMessage, []*crossmessage.InputMetaData, crossmessage.ContentType, error) {
|
||||
|
||||
var multiContent []*message.InputMetaData
|
||||
var contentType message.ContentType
|
||||
var multiContent []*crossmessage.InputMetaData
|
||||
var contentType crossmessage.ContentType
|
||||
var filterMultiAdditionalMessages []*entity.AdditionalMessage
|
||||
filterMultiAdditionalMessages = multiAdditionalMessages
|
||||
|
||||
@ -258,7 +259,7 @@ func (a *OpenapiAgentRunApplication) parseAdditionalMessages(ctx context.Context
|
||||
if item.Role != string(schema.User) && item.Role != string(schema.Assistant) {
|
||||
return nil, errors.New("additional message role only support user and assistant")
|
||||
}
|
||||
if item.Type != nil && !slices.Contains([]message.MessageType{message.MessageTypeQuestion, message.MessageTypeAnswer}, message.MessageType(*item.Type)) {
|
||||
if item.Type != nil && !slices.Contains([]crossmessage.MessageType{crossmessage.MessageTypeQuestion, crossmessage.MessageTypeAnswer}, crossmessage.MessageType(*item.Type)) {
|
||||
return nil, errors.New("additional message type only support question and answer now")
|
||||
}
|
||||
|
||||
@ -266,9 +267,9 @@ func (a *OpenapiAgentRunApplication) parseAdditionalMessages(ctx context.Context
|
||||
Role: schema.RoleType(item.Role),
|
||||
}
|
||||
if item.Type != nil {
|
||||
addOne.Type = message.MessageType(*item.Type)
|
||||
addOne.Type = crossmessage.MessageType(*item.Type)
|
||||
} else {
|
||||
addOne.Type = message.MessageTypeQuestion
|
||||
addOne.Type = crossmessage.MessageTypeQuestion
|
||||
}
|
||||
|
||||
if item.ContentType == run.ContentTypeText {
|
||||
@ -276,20 +277,20 @@ func (a *OpenapiAgentRunApplication) parseAdditionalMessages(ctx context.Context
|
||||
continue
|
||||
}
|
||||
|
||||
addOne.ContentType = message.ContentTypeText
|
||||
addOne.Content = []*message.InputMetaData{{
|
||||
Type: message.InputTypeText,
|
||||
addOne.ContentType = crossmessage.ContentTypeText
|
||||
addOne.Content = []*crossmessage.InputMetaData{{
|
||||
Type: crossmessage.InputTypeText,
|
||||
Text: item.Content,
|
||||
}}
|
||||
}
|
||||
|
||||
if item.ContentType == run.ContentTypeMixApi {
|
||||
|
||||
if ptr.From(item.Type) == string(message.MessageTypeAnswer) {
|
||||
if ptr.From(item.Type) == string(crossmessage.MessageTypeAnswer) {
|
||||
return nil, errors.New(" answer messages only support text content")
|
||||
}
|
||||
|
||||
addOne.ContentType = message.ContentTypeMix
|
||||
addOne.ContentType = crossmessage.ContentTypeMix
|
||||
var inputs []*run.AdditionalContent
|
||||
err := json.Unmarshal([]byte(item.Content), &inputs)
|
||||
|
||||
@ -301,14 +302,14 @@ func (a *OpenapiAgentRunApplication) parseAdditionalMessages(ctx context.Context
|
||||
if one == nil {
|
||||
continue
|
||||
}
|
||||
switch message.InputType(one.Type) {
|
||||
case message.InputTypeText:
|
||||
switch crossmessage.InputType(one.Type) {
|
||||
case crossmessage.InputTypeText:
|
||||
|
||||
addOne.Content = append(addOne.Content, &message.InputMetaData{
|
||||
Type: message.InputTypeText,
|
||||
addOne.Content = append(addOne.Content, &crossmessage.InputMetaData{
|
||||
Type: crossmessage.InputTypeText,
|
||||
Text: ptr.From(one.Text),
|
||||
})
|
||||
case message.InputTypeImage, message.InputTypeFile:
|
||||
case crossmessage.InputTypeImage, crossmessage.InputTypeFile:
|
||||
|
||||
var fileUrl, fileURI string
|
||||
if one.GetFileURL() != "" {
|
||||
@ -323,9 +324,9 @@ func (a *OpenapiAgentRunApplication) parseAdditionalMessages(ctx context.Context
|
||||
fileUrl = fileInfo.File.Url
|
||||
fileURI = fileInfo.File.TosURI
|
||||
}
|
||||
addOne.Content = append(addOne.Content, &message.InputMetaData{
|
||||
Type: message.InputType(one.Type),
|
||||
FileData: []*message.FileData{
|
||||
addOne.Content = append(addOne.Content, &crossmessage.InputMetaData{
|
||||
Type: crossmessage.InputType(one.Type),
|
||||
FileData: []*crossmessage.FileData{
|
||||
{
|
||||
Url: fileUrl,
|
||||
URI: fileURI,
|
||||
@ -417,6 +418,212 @@ func buildARSM2ApiChatMessage(chunk *entity.AgentRunResponse) []byte {
|
||||
return mCM
|
||||
}
|
||||
|
||||
func (a *OpenapiAgentRunApplication) RetrieveRunRecord(ctx context.Context, req *run.RetrieveChatOpenRequest) (*run.RetrieveChatOpenResponse, error) {
|
||||
resp := new(run.RetrieveChatOpenResponse)
|
||||
|
||||
apiKeyInfo := ctxutil.GetApiAuthFromCtx(ctx)
|
||||
userID := apiKeyInfo.UserID
|
||||
|
||||
// Get agent run record by chat ID
|
||||
runRecord, err := ConversationSVC.AgentRunDomainSVC.GetByID(ctx, req.ChatID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if runRecord == nil {
|
||||
return nil, errorx.New(errno.ErrRecordNotFound)
|
||||
}
|
||||
|
||||
// Get conversation data and check permissions
|
||||
conversationData, err := ConversationSVC.ConversationDomainSVC.GetByID(ctx, req.ConversationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if userID != conversationData.CreatorID {
|
||||
return nil, errorx.New(errno.ErrConversationPermissionCode, errorx.KV("msg", "user not match"))
|
||||
}
|
||||
|
||||
// Build response with chat detail
|
||||
resp.ChatDetail = &run.ChatV3ChatDetail{
|
||||
ID: runRecord.ID,
|
||||
ConversationID: runRecord.ConversationID,
|
||||
BotID: runRecord.AgentID,
|
||||
Status: string(runRecord.Status),
|
||||
SectionID: ptr.Of(runRecord.SectionID),
|
||||
CreatedAt: ptr.Of(int32(runRecord.CreatedAt / 1000)),
|
||||
CompletedAt: ptr.Of(int32(runRecord.CompletedAt / 1000)),
|
||||
FailedAt: ptr.Of(int32(runRecord.FailedAt / 1000)),
|
||||
}
|
||||
|
||||
// Add usage information if available
|
||||
if runRecord.Usage != nil {
|
||||
resp.ChatDetail.Usage = &run.Usage{
|
||||
TokenCount: ptr.Of(int32(runRecord.Usage.LlmTotalTokens)),
|
||||
InputTokens: ptr.Of(int32(runRecord.Usage.LlmPromptTokens)),
|
||||
OutputTokens: ptr.Of(int32(runRecord.Usage.LlmCompletionTokens)),
|
||||
}
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (a *OpenapiAgentRunApplication) ListChatMessageApi(ctx context.Context, req *message.ListChatMessageApiRequest) (*message.ListChatMessageApiResponse, error) {
|
||||
resp := new(message.ListChatMessageApiResponse)
|
||||
|
||||
apiKeyInfo := ctxutil.GetApiAuthFromCtx(ctx)
|
||||
userID := apiKeyInfo.UserID
|
||||
|
||||
// Get conversation data and check permissions
|
||||
conversationData, err := ConversationSVC.ConversationDomainSVC.GetByID(ctx, req.ConversationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if userID != conversationData.CreatorID {
|
||||
return nil, errorx.New(errno.ErrConversationPermissionCode, errorx.KV("msg", "user not match"))
|
||||
}
|
||||
|
||||
// Get messages by run IDs
|
||||
messages, err := ConversationSVC.MessageDomainSVC.GetByRunIDs(ctx, req.ConversationID, []int64{req.ChatID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Convert domain messages to API messages
|
||||
var apiMessages []*message.ChatV3MessageDetail
|
||||
for _, msg := range messages {
|
||||
apiMessage := &message.ChatV3MessageDetail{
|
||||
ID: msg.ID,
|
||||
ConversationID: msg.ConversationID,
|
||||
BotID: msg.AgentID,
|
||||
Role: string(msg.Role),
|
||||
Type: string(msg.MessageType),
|
||||
Content: msg.Content,
|
||||
ContentType: string(msg.ContentType),
|
||||
MetaData: msg.Ext,
|
||||
ChatID: msg.RunID,
|
||||
ReasoningContent: ptr.Of(msg.ReasoningContent),
|
||||
CreatedAt: ptr.Of(msg.CreatedAt / 1000),
|
||||
SectionID: ptr.Of(msg.SectionID),
|
||||
}
|
||||
apiMessages = append(apiMessages, apiMessage)
|
||||
}
|
||||
|
||||
resp.Messages = apiMessages
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (a *OpenapiAgentRunApplication) OpenapiAgentRunSync(ctx context.Context, ar *run.ChatV3Request) (*run.RetrieveChatOpenResponse, error) {
|
||||
apiKeyInfo := ctxutil.GetApiAuthFromCtx(ctx)
|
||||
creatorID := apiKeyInfo.UserID
|
||||
connectorID := apiKeyInfo.ConnectorID
|
||||
|
||||
if ptr.From(ar.ConnectorID) == consts.WebSDKConnectorID {
|
||||
connectorID = ptr.From(ar.ConnectorID)
|
||||
}
|
||||
agentInfo, caErr := a.checkAgent(ctx, ar, connectorID)
|
||||
if caErr != nil {
|
||||
logs.CtxErrorf(ctx, "checkAgent err:%v", caErr)
|
||||
return nil, caErr
|
||||
}
|
||||
|
||||
conversationData, ccErr := a.checkConversation(ctx, ar, creatorID, connectorID)
|
||||
if ccErr != nil {
|
||||
logs.CtxErrorf(ctx, "checkConversation err:%v", ccErr)
|
||||
return nil, ccErr
|
||||
}
|
||||
|
||||
spaceID := agentInfo.SpaceID
|
||||
arr, err := a.buildAgentRunRequest(ctx, ar, connectorID, spaceID, conversationData)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "buildAgentRunRequest err:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Execute agent run synchronously
|
||||
streamer, err := ConversationSVC.AgentRunDomainSVC.AgentRun(ctx, arr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var finalChatDetail *run.ChatV3ChatDetail
|
||||
var backgroundProcessingStarted bool
|
||||
|
||||
startBackgroundProcessing := func() {
|
||||
if !backgroundProcessingStarted {
|
||||
backgroundProcessingStarted = true
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
logs.CtxErrorf(ctx, "background stream processing panic: %v", r)
|
||||
}
|
||||
}()
|
||||
for {
|
||||
_, recvErr := streamer.Recv()
|
||||
if recvErr != nil {
|
||||
if errors.Is(recvErr, io.EOF) {
|
||||
logs.CtxInfof(ctx, "background stream processing completed")
|
||||
} else {
|
||||
logs.CtxErrorf(ctx, "background stream processing error: %v", recvErr)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
chunk, recvErr := streamer.Recv()
|
||||
logs.CtxInfof(ctx, "chunk :%v, err:%v", conv.DebugJsonToStr(chunk), recvErr)
|
||||
if recvErr != nil {
|
||||
if errors.Is(recvErr, io.EOF) {
|
||||
break
|
||||
}
|
||||
return nil, errorx.New(errno.ErrConversationAgentRunError, errorx.KV("msg", recvErr.Error()))
|
||||
}
|
||||
|
||||
switch chunk.Event {
|
||||
case entity.RunEventError:
|
||||
return nil, errorx.New(int32(chunk.Error.Code), errorx.KV("msg", chunk.Error.Msg))
|
||||
case entity.RunEventCreated:
|
||||
chunkRunItem := chunk.ChunkRunItem
|
||||
finalChatDetail = &run.ChatV3ChatDetail{
|
||||
ID: chunkRunItem.ID,
|
||||
ConversationID: chunkRunItem.ConversationID,
|
||||
BotID: chunkRunItem.AgentID,
|
||||
Status: string(chunkRunItem.Status),
|
||||
SectionID: ptr.Of(chunkRunItem.SectionID),
|
||||
CreatedAt: ptr.Of(int32(chunkRunItem.CreatedAt / 1000)),
|
||||
CompletedAt: ptr.Of(int32(chunkRunItem.CompletedAt / 1000)),
|
||||
FailedAt: ptr.Of(int32(chunkRunItem.FailedAt / 1000)),
|
||||
}
|
||||
if chunkRunItem.Usage != nil {
|
||||
finalChatDetail.Usage = &run.Usage{
|
||||
TokenCount: ptr.Of(int32(chunkRunItem.Usage.LlmTotalTokens)),
|
||||
InputTokens: ptr.Of(int32(chunkRunItem.Usage.LlmPromptTokens)),
|
||||
OutputTokens: ptr.Of(int32(chunkRunItem.Usage.LlmCompletionTokens)),
|
||||
}
|
||||
}
|
||||
startBackgroundProcessing()
|
||||
goto exitLoop
|
||||
default:
|
||||
logs.CtxInfof(ctx, "received event: %v, starting background processing and continuing to listen", chunk.Event)
|
||||
startBackgroundProcessing()
|
||||
}
|
||||
}
|
||||
exitLoop:
|
||||
|
||||
if finalChatDetail == nil {
|
||||
return nil, errorx.New(errno.ErrConversationAgentRunError, errorx.KV("msg", "no final result received"))
|
||||
}
|
||||
|
||||
resp := &run.RetrieveChatOpenResponse{
|
||||
ChatDetail: finalChatDetail,
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (a *OpenapiAgentRunApplication) CancelRun(ctx context.Context, req *run.CancelChatApiRequest) (*run.CancelChatApiResponse, error) {
|
||||
resp := new(run.CancelChatApiResponse)
|
||||
|
||||
|
||||
@ -19,15 +19,19 @@ package conversation
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||
singleagent "github.com/coze-dev/coze-studio/backend/crossdomain/agent/model"
|
||||
agentrun "github.com/coze-dev/coze-studio/backend/crossdomain/agentrun/model"
|
||||
saEntity "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
convEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
openapiEntity "github.com/coze-dev/coze-studio/backend/domain/openauth/openapiauth/entity"
|
||||
cmdEntity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||
@ -899,3 +903,274 @@ func TestOpenapiAgentRun_ParseAdditionalMessages_NilMessage(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "mock stream error")
|
||||
}
|
||||
|
||||
type MockStreamReader struct {
|
||||
chunks []*entity.AgentRunResponse
|
||||
index int
|
||||
}
|
||||
|
||||
func (m *MockStreamReader) Recv() (*entity.AgentRunResponse, error) {
|
||||
if m.index >= len(m.chunks) {
|
||||
return nil, io.EOF
|
||||
}
|
||||
response := m.chunks[m.index]
|
||||
m.index++
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
||||
func newMockStreamReader(chunks []*entity.AgentRunResponse) *schema.StreamReader[*entity.AgentRunResponse] {
|
||||
|
||||
sr, sw := schema.Pipe[*entity.AgentRunResponse](10)
|
||||
|
||||
go func() {
|
||||
defer sw.Close()
|
||||
for _, chunk := range chunks {
|
||||
sw.Send(chunk, nil)
|
||||
}
|
||||
}()
|
||||
|
||||
return sr
|
||||
}
|
||||
|
||||
func TestOpenapiAgentRunSync_Success(t *testing.T) {
|
||||
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||
ctx := createTestContext()
|
||||
|
||||
req := &run.ChatV3Request{
|
||||
BotID: 67890,
|
||||
ConversationID: ptr.Of(int64(11111)),
|
||||
User: "test-user",
|
||||
AdditionalMessages: []*run.EnterMessage{
|
||||
{
|
||||
Role: "user",
|
||||
Content: "test query",
|
||||
ContentType: run.ContentTypeText,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Mock agent check success
|
||||
mockAgent := &saEntity.SingleAgent{
|
||||
SingleAgent: &singleagent.SingleAgent{
|
||||
AgentID: 67890,
|
||||
SpaceID: 54321,
|
||||
},
|
||||
}
|
||||
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||
|
||||
// Mock conversation check success
|
||||
mockConv := &convEntity.Conversation{
|
||||
ID: 11111,
|
||||
CreatorID: 12345,
|
||||
SectionID: 98765,
|
||||
}
|
||||
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||
|
||||
// Mock successful agent run with stream
|
||||
mockStream := newMockStreamReader([]*entity.AgentRunResponse{
|
||||
{
|
||||
Event: entity.RunEventCreated,
|
||||
ChunkRunItem: &entity.RunRecordMeta{
|
||||
ID: 999,
|
||||
ConversationID: 11111,
|
||||
AgentID: 67890,
|
||||
Status: entity.RunStatusCompleted,
|
||||
SectionID: 98765,
|
||||
CreatedAt: 1640995200000, // 2022-01-01 00:00:00
|
||||
CompletedAt: 1640995260000, // 2022-01-01 00:01:00
|
||||
Usage: &agentrun.Usage{
|
||||
LlmTotalTokens: 100,
|
||||
LlmPromptTokens: 60,
|
||||
LlmCompletionTokens: 40,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(mockStream, nil)
|
||||
|
||||
result, err := app.OpenapiAgentRunSync(ctx, req)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
assert.NotNil(t, result.ChatDetail)
|
||||
assert.Equal(t, int64(999), result.ChatDetail.ID)
|
||||
assert.Equal(t, int64(11111), result.ChatDetail.ConversationID)
|
||||
assert.Equal(t, int64(67890), result.ChatDetail.BotID)
|
||||
assert.Equal(t, string(entity.RunStatusCompleted), result.ChatDetail.Status)
|
||||
assert.Equal(t, ptr.Of(int64(98765)), result.ChatDetail.SectionID)
|
||||
assert.Equal(t, ptr.Of(int32(1640995200)), result.ChatDetail.CreatedAt)
|
||||
assert.Equal(t, ptr.Of(int32(1640995260)), result.ChatDetail.CompletedAt)
|
||||
assert.NotNil(t, result.ChatDetail.Usage)
|
||||
assert.Equal(t, ptr.Of(int32(100)), result.ChatDetail.Usage.TokenCount)
|
||||
assert.Equal(t, ptr.Of(int32(60)), result.ChatDetail.Usage.InputTokens)
|
||||
assert.Equal(t, ptr.Of(int32(40)), result.ChatDetail.Usage.OutputTokens)
|
||||
}
|
||||
|
||||
func TestOpenapiAgentRunSync_AgentNotFound(t *testing.T) {
|
||||
app, _, _, _, _, mockSingleAgent, _ := setupMocks(t)
|
||||
ctx := createTestContext()
|
||||
|
||||
req := &run.ChatV3Request{
|
||||
BotID: 67890,
|
||||
AdditionalMessages: []*run.EnterMessage{
|
||||
{
|
||||
Role: "user",
|
||||
Content: "test query",
|
||||
ContentType: run.ContentTypeText,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Mock agent check failure
|
||||
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(nil, nil)
|
||||
|
||||
result, err := app.OpenapiAgentRunSync(ctx, req)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, result)
|
||||
assert.Contains(t, err.Error(), "agent not exists")
|
||||
}
|
||||
|
||||
func TestOpenapiAgentRunSync_ConversationPermissionError(t *testing.T) {
|
||||
app, _, _, _, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||
ctx := createTestContext()
|
||||
|
||||
req := &run.ChatV3Request{
|
||||
BotID: 67890,
|
||||
ConversationID: ptr.Of(int64(11111)),
|
||||
AdditionalMessages: []*run.EnterMessage{
|
||||
{
|
||||
Role: "user",
|
||||
Content: "test query",
|
||||
ContentType: run.ContentTypeText,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Mock agent check success
|
||||
mockAgent := &saEntity.SingleAgent{
|
||||
SingleAgent: &singleagent.SingleAgent{
|
||||
AgentID: 67890,
|
||||
SpaceID: 54321,
|
||||
},
|
||||
}
|
||||
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||
|
||||
// Mock conversation check with wrong user
|
||||
mockConv := &convEntity.Conversation{
|
||||
ID: 11111,
|
||||
CreatorID: 99999, // Different user ID
|
||||
SectionID: 98765,
|
||||
}
|
||||
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||
|
||||
result, err := app.OpenapiAgentRunSync(ctx, req)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, result)
|
||||
assert.Contains(t, err.Error(), "user not match")
|
||||
}
|
||||
|
||||
func TestOpenapiAgentRunSync_StreamError(t *testing.T) {
|
||||
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||
ctx := createTestContext()
|
||||
|
||||
req := &run.ChatV3Request{
|
||||
BotID: 67890,
|
||||
ConversationID: ptr.Of(int64(11111)),
|
||||
User: "test-user",
|
||||
AdditionalMessages: []*run.EnterMessage{
|
||||
{
|
||||
Role: "user",
|
||||
Content: "test query",
|
||||
ContentType: run.ContentTypeText,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Mock agent check success
|
||||
mockAgent := &saEntity.SingleAgent{
|
||||
SingleAgent: &singleagent.SingleAgent{
|
||||
AgentID: 67890,
|
||||
SpaceID: 54321,
|
||||
},
|
||||
}
|
||||
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||
|
||||
// Mock conversation check success
|
||||
mockConv := &convEntity.Conversation{
|
||||
ID: 11111,
|
||||
CreatorID: 12345,
|
||||
SectionID: 98765,
|
||||
}
|
||||
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||
|
||||
// Mock stream with error event
|
||||
mockStream := newMockStreamReader([]*entity.AgentRunResponse{
|
||||
{
|
||||
Event: entity.RunEventError,
|
||||
Error: &entity.RunError{
|
||||
Code: 500,
|
||||
Msg: "agent run failed",
|
||||
},
|
||||
},
|
||||
})
|
||||
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(mockStream, nil)
|
||||
|
||||
result, err := app.OpenapiAgentRunSync(ctx, req)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, result)
|
||||
|
||||
assert.Contains(t, err.Error(), "code=500")
|
||||
}
|
||||
|
||||
func TestOpenapiAgentRunSync_NoFinalResult(t *testing.T) {
|
||||
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||
ctx := createTestContext()
|
||||
|
||||
req := &run.ChatV3Request{
|
||||
BotID: 67890,
|
||||
ConversationID: ptr.Of(int64(11111)),
|
||||
User: "test-user",
|
||||
AdditionalMessages: []*run.EnterMessage{
|
||||
{
|
||||
Role: "user",
|
||||
Content: "test query",
|
||||
ContentType: run.ContentTypeText,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Mock agent check success
|
||||
mockAgent := &saEntity.SingleAgent{
|
||||
SingleAgent: &singleagent.SingleAgent{
|
||||
AgentID: 67890,
|
||||
SpaceID: 54321,
|
||||
},
|
||||
}
|
||||
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||
|
||||
// Mock conversation check success
|
||||
mockConv := &convEntity.Conversation{
|
||||
ID: 11111,
|
||||
CreatorID: 12345,
|
||||
SectionID: 98765,
|
||||
}
|
||||
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||
|
||||
// Mock stream with no RunEventCreated event
|
||||
mockStream := newMockStreamReader([]*entity.AgentRunResponse{
|
||||
{
|
||||
Event: entity.RunEventMessageDelta, // Different event type
|
||||
},
|
||||
})
|
||||
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(mockStream, nil)
|
||||
|
||||
result, err := app.OpenapiAgentRunSync(ctx, req)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, result)
|
||||
assert.Contains(t, err.Error(), "no final result received")
|
||||
}
|
||||
|
||||
@ -341,8 +341,6 @@ github.com/elastic/elastic-transport-go/v8 v8.7.0 h1:OgTneVuXP2uip4BA658Xi6Hfw+P
|
||||
github.com/elastic/elastic-transport-go/v8 v8.7.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk=
|
||||
github.com/elastic/go-elasticsearch/v7 v7.17.10 h1:TCQ8i4PmIJuBunvBS6bwT2ybzVFxxUhhltAs3Gyu1yo=
|
||||
github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.18.0 h1:ANNq1h7DEiPUaALb8+5w3baQzaS08WfHV0DNzp0VG4M=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.18.0/go.mod h1:WLqwXsJmQoYkoA9JBFeEwPkQhCfAZuUvfpdU/NvSSf0=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.19.0 h1:VmfBLNRORY7RZL+9hTxBD97ehl9H8Nxf2QigDh6HuMU=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.19.0/go.mod h1:F3j9e+BubmKvzvLjNui/1++nJuJxbkhHefbaT0kFKGY=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
|
||||
@ -6,4 +6,5 @@ service AgentRunService {
|
||||
run.AgentRunResponse AgentRun(1: run.AgentRunRequest request)(api.post='/api/conversation/chat', api.category="conversation", api.gen_path= "agent_run")
|
||||
run.ChatV3Response ChatV3(1: run.ChatV3Request request)(api.post = "/v3/chat", api.category="chat", api.tag="openapi", api.gen_path="chat")
|
||||
run.CancelChatApiResponse CancelChatApi(1: run.CancelChatApiRequest request) (api.post = '/v3/chat/cancel', api.category = "chat", api.tag="openapi", agw.preserve_base = "true")
|
||||
run.RetrieveChatOpenResponse RetrieveChatOpen(1: run.RetrieveChatOpenRequest request) (api.get = "/v3/chat/retrieve", api.tag="openapi", agw.preserve_base = "true")
|
||||
}
|
||||
@ -217,3 +217,33 @@ struct ListMessageApiResponse {
|
||||
253: i64 code
|
||||
254: string msg
|
||||
}
|
||||
|
||||
|
||||
struct ChatV3MessageDetail {
|
||||
1: required i64 ID (api.body = "id",api.js_conv='true'),
|
||||
2: required i64 ConversationID (api.body = "conversation_id",api.js_conv='true'),
|
||||
3: required i64 BotID (api.body = "bot_id",api.js_conv='true'),
|
||||
4: required string Role (api.body = "role"),
|
||||
5: required string Type (api.body = "type"),
|
||||
6: required string Content (api.body = "content"),
|
||||
7: required string ContentType (api.body = "content_type"),
|
||||
8: optional map<string, string> MetaData (api.body = "meta_data"),
|
||||
9: required i64 ChatID (api.body = "chat_id",api.js_conv='true')
|
||||
10: optional i64 SectionID (api.body="section_id",api.js_conv='true')
|
||||
11: optional i64 CreatedAt (api.body = "created_at")
|
||||
12: optional i64 UpdatedAt (api.body = "updated_at")
|
||||
13: optional string ReasoningContent (api.body = "reasoning_content")
|
||||
}
|
||||
|
||||
struct ListChatMessageApiRequest {
|
||||
1: required i64 ConversationID (api.query = "conversation_id", agw.source = "query", agw.key = "conversation_id", api.js_conv='true'), //connector层的会话id
|
||||
2: required i64 ChatID (api.query = "chat_id", agw.source = "query", agw.key = "chat_id", api.js_conv='true'),
|
||||
255: base.Base Base
|
||||
}
|
||||
|
||||
struct ListChatMessageApiResponse {
|
||||
1: optional list<ChatV3MessageDetail> Messages (agw.key = "data")
|
||||
253: i64 code
|
||||
254: string msg
|
||||
255: base.BaseResp BaseResp
|
||||
}
|
||||
|
||||
@ -7,4 +7,6 @@ service MessageService {
|
||||
message.DeleteMessageResponse DeleteMessage(1: message.DeleteMessageRequest request)(api.post='/api/conversation/delete_message', api.category="conversation", api.gen_path= "message")
|
||||
message.BreakMessageResponse BreakMessage(1: message.BreakMessageRequest request)(api.post='/api/conversation/break_message', api.category="conversation", api.gen_path= "message")
|
||||
message.ListMessageApiResponse GetApiMessageList(1: message.ListMessageApiRequest request)(api.post='/v1/conversation/message/list', api.category="conversation", api.gen_path= "message")
|
||||
|
||||
message.ListChatMessageApiResponse ListChatMessageApi(1: message.ListChatMessageApiRequest request) (api.get = '/v3/chat/message/list', api.category = "message", api.tag="openapi", agw.preserve_base = "true") //查询单次运行的消息列表
|
||||
}
|
||||
@ -258,3 +258,17 @@ struct CancelChatApiResponse {
|
||||
1: ChatV3ChatDetail ChatV3ChatDetail (agw.key = "data")
|
||||
255: base.BaseResp BaseResp
|
||||
}
|
||||
|
||||
struct RetrieveChatOpenRequest {
|
||||
1: required i64 ConversationID (api.query = "conversation_id", agw.source = "query", agw.key = "conversation_id", api.js_conv='true'),
|
||||
2: required i64 ChatID (api.query = "chat_id", agw.source = "query", agw.key = "chat_id", api.js_conv='true'),
|
||||
255: base.Base Base
|
||||
}
|
||||
|
||||
struct RetrieveChatOpenResponse {
|
||||
1: optional ChatV3ChatDetail ChatDetail (api.body = "data", agw.key = "data")
|
||||
|
||||
253: required i32 Code (api.body = "code"),
|
||||
254: required string Msg (api.body = "msg")
|
||||
255: base.BaseResp BaseResp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user