feat: add conversation retrieve api & return section id field in chat… (#2408)
This commit is contained in:
@ -209,3 +209,23 @@ func DeleteConversationApi(ctx context.Context, c *app.RequestContext) {
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// RetrieveConversationApi .
|
||||
// @router /v1/conversation/retrieve [GET]
|
||||
func RetrieveConversationApi(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req conversation.RetrieveConversationApiRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := application.ConversationSVC.RetrieveConversation(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@ var needAuthPath = map[string]bool{
|
||||
"/v1/workflows/chat": true,
|
||||
"/v1/workflow/conversation/create": true,
|
||||
"/v3/chat/cancel": true,
|
||||
"/v1/conversation/retrieve": 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 conversation
|
||||
|
||||
@ -4678,3 +4678,497 @@ func (p *DeleteConversationApiResponse) String() string {
|
||||
return fmt.Sprintf("DeleteConversationApiResponse(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type RetrieveConversationApiRequest struct {
|
||||
ConversationID int64 `thrift:"ConversationID,1,required" json:"ConversationID,string,required" query:"conversation_id,required"`
|
||||
Base *base.Base `thrift:"Base,255" form:"Base" json:"Base" query:"Base"`
|
||||
}
|
||||
|
||||
func NewRetrieveConversationApiRequest() *RetrieveConversationApiRequest {
|
||||
return &RetrieveConversationApiRequest{}
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiRequest) InitDefault() {
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiRequest) GetConversationID() (v int64) {
|
||||
return p.ConversationID
|
||||
}
|
||||
|
||||
var RetrieveConversationApiRequest_Base_DEFAULT *base.Base
|
||||
|
||||
func (p *RetrieveConversationApiRequest) GetBase() (v *base.Base) {
|
||||
if !p.IsSetBase() {
|
||||
return RetrieveConversationApiRequest_Base_DEFAULT
|
||||
}
|
||||
return p.Base
|
||||
}
|
||||
|
||||
var fieldIDToName_RetrieveConversationApiRequest = map[int16]string{
|
||||
1: "ConversationID",
|
||||
255: "Base",
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiRequest) IsSetBase() bool {
|
||||
return p.Base != nil
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiRequest) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
var issetConversationID 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 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
|
||||
}
|
||||
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_RetrieveConversationApiRequest[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_RetrieveConversationApiRequest[fieldId]))
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiRequest) 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 *RetrieveConversationApiRequest) ReadField255(iprot thrift.TProtocol) error {
|
||||
_field := base.NewBase()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Base = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiRequest) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveConversationApiRequest"); err != nil {
|
||||
goto WriteStructBeginError
|
||||
}
|
||||
if p != nil {
|
||||
if err = p.writeField1(oprot); err != nil {
|
||||
fieldId = 1
|
||||
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 *RetrieveConversationApiRequest) 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 *RetrieveConversationApiRequest) 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 *RetrieveConversationApiRequest) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("RetrieveConversationApiRequest(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type RetrieveConversationApiResponse struct {
|
||||
ConversationData *ConversationData `thrift:"ConversationData,1,optional" form:"ConversationData" json:"ConversationData,omitempty" query:"ConversationData"`
|
||||
Code int32 `thrift:"Code,253" form:"code" json:"code"`
|
||||
Msg string `thrift:"Msg,254" form:"msg" json:"msg"`
|
||||
BaseResp *base.BaseResp `thrift:"BaseResp,255,required" form:"BaseResp,required" json:"BaseResp,required" query:"BaseResp,required"`
|
||||
}
|
||||
|
||||
func NewRetrieveConversationApiResponse() *RetrieveConversationApiResponse {
|
||||
return &RetrieveConversationApiResponse{}
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) InitDefault() {
|
||||
}
|
||||
|
||||
var RetrieveConversationApiResponse_ConversationData_DEFAULT *ConversationData
|
||||
|
||||
func (p *RetrieveConversationApiResponse) GetConversationData() (v *ConversationData) {
|
||||
if !p.IsSetConversationData() {
|
||||
return RetrieveConversationApiResponse_ConversationData_DEFAULT
|
||||
}
|
||||
return p.ConversationData
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) GetCode() (v int32) {
|
||||
return p.Code
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) GetMsg() (v string) {
|
||||
return p.Msg
|
||||
}
|
||||
|
||||
var RetrieveConversationApiResponse_BaseResp_DEFAULT *base.BaseResp
|
||||
|
||||
func (p *RetrieveConversationApiResponse) GetBaseResp() (v *base.BaseResp) {
|
||||
if !p.IsSetBaseResp() {
|
||||
return RetrieveConversationApiResponse_BaseResp_DEFAULT
|
||||
}
|
||||
return p.BaseResp
|
||||
}
|
||||
|
||||
var fieldIDToName_RetrieveConversationApiResponse = map[int16]string{
|
||||
1: "ConversationData",
|
||||
253: "Code",
|
||||
254: "Msg",
|
||||
255: "BaseResp",
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) IsSetConversationData() bool {
|
||||
return p.ConversationData != nil
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) IsSetBaseResp() bool {
|
||||
return p.BaseResp != nil
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) Read(iprot thrift.TProtocol) (err error) {
|
||||
var fieldTypeId thrift.TType
|
||||
var fieldId int16
|
||||
var issetBaseResp 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
|
||||
}
|
||||
} 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
|
||||
}
|
||||
} 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
|
||||
}
|
||||
issetBaseResp = true
|
||||
} 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 !issetBaseResp {
|
||||
fieldId = 255
|
||||
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_RetrieveConversationApiResponse[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_RetrieveConversationApiResponse[fieldId]))
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) ReadField1(iprot thrift.TProtocol) error {
|
||||
_field := NewConversationData()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.ConversationData = _field
|
||||
return nil
|
||||
}
|
||||
func (p *RetrieveConversationApiResponse) 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 *RetrieveConversationApiResponse) 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 *RetrieveConversationApiResponse) ReadField255(iprot thrift.TProtocol) error {
|
||||
_field := base.NewBaseResp()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.BaseResp = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *RetrieveConversationApiResponse) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveConversationApiResponse"); 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 *RetrieveConversationApiResponse) writeField1(oprot thrift.TProtocol) (err error) {
|
||||
if p.IsSetConversationData() {
|
||||
if err = oprot.WriteFieldBegin("ConversationData", thrift.STRUCT, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.ConversationData.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 *RetrieveConversationApiResponse) 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 *RetrieveConversationApiResponse) 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 *RetrieveConversationApiResponse) 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 *RetrieveConversationApiResponse) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("RetrieveConversationApiResponse(%+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 conversation
|
||||
|
||||
@ -22,6 +22,8 @@ type ConversationService interface {
|
||||
UpdateConversationApi(ctx context.Context, request *UpdateConversationApiRequest) (r *UpdateConversationApiResponse, err error)
|
||||
|
||||
DeleteConversationApi(ctx context.Context, req *DeleteConversationApiRequest) (r *DeleteConversationApiResponse, err error)
|
||||
|
||||
RetrieveConversationApi(ctx context.Context, request *RetrieveConversationApiRequest) (r *RetrieveConversationApiResponse, err error)
|
||||
}
|
||||
|
||||
type ConversationServiceClient struct {
|
||||
@ -113,6 +115,15 @@ func (p *ConversationServiceClient) DeleteConversationApi(ctx context.Context, r
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
func (p *ConversationServiceClient) RetrieveConversationApi(ctx context.Context, request *RetrieveConversationApiRequest) (r *RetrieveConversationApiResponse, err error) {
|
||||
var _args ConversationServiceRetrieveConversationApiArgs
|
||||
_args.Request = request
|
||||
var _result ConversationServiceRetrieveConversationApiResult
|
||||
if err = p.Client_().Call(ctx, "RetrieveConversationApi", &_args, &_result); err != nil {
|
||||
return
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
|
||||
type ConversationServiceProcessor struct {
|
||||
processorMap map[string]thrift.TProcessorFunction
|
||||
@ -141,6 +152,7 @@ func NewConversationServiceProcessor(handler ConversationService) *ConversationS
|
||||
self.AddToProcessorMap("ListConversationsApi", &conversationServiceProcessorListConversationsApi{handler: handler})
|
||||
self.AddToProcessorMap("UpdateConversationApi", &conversationServiceProcessorUpdateConversationApi{handler: handler})
|
||||
self.AddToProcessorMap("DeleteConversationApi", &conversationServiceProcessorDeleteConversationApi{handler: handler})
|
||||
self.AddToProcessorMap("RetrieveConversationApi", &conversationServiceProcessorRetrieveConversationApi{handler: handler})
|
||||
return self
|
||||
}
|
||||
func (p *ConversationServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
@ -497,6 +509,54 @@ func (p *conversationServiceProcessorDeleteConversationApi) Process(ctx context.
|
||||
return true, err
|
||||
}
|
||||
|
||||
type conversationServiceProcessorRetrieveConversationApi struct {
|
||||
handler ConversationService
|
||||
}
|
||||
|
||||
func (p *conversationServiceProcessorRetrieveConversationApi) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
|
||||
args := ConversationServiceRetrieveConversationApiArgs{}
|
||||
if err = args.Read(iprot); err != nil {
|
||||
iprot.ReadMessageEnd()
|
||||
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
|
||||
oprot.WriteMessageBegin("RetrieveConversationApi", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return false, err
|
||||
}
|
||||
|
||||
iprot.ReadMessageEnd()
|
||||
var err2 error
|
||||
result := ConversationServiceRetrieveConversationApiResult{}
|
||||
var retval *RetrieveConversationApiResponse
|
||||
if retval, err2 = p.handler.RetrieveConversationApi(ctx, args.Request); err2 != nil {
|
||||
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing RetrieveConversationApi: "+err2.Error())
|
||||
oprot.WriteMessageBegin("RetrieveConversationApi", thrift.EXCEPTION, seqId)
|
||||
x.Write(oprot)
|
||||
oprot.WriteMessageEnd()
|
||||
oprot.Flush(ctx)
|
||||
return true, err2
|
||||
} else {
|
||||
result.Success = retval
|
||||
}
|
||||
if err2 = oprot.WriteMessageBegin("RetrieveConversationApi", 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 ConversationServiceClearConversationCtxArgs struct {
|
||||
Request *ClearConversationCtxRequest `thrift:"request,1"`
|
||||
}
|
||||
@ -2540,3 +2600,295 @@ func (p *ConversationServiceDeleteConversationApiResult) String() string {
|
||||
return fmt.Sprintf("ConversationServiceDeleteConversationApiResult(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type ConversationServiceRetrieveConversationApiArgs struct {
|
||||
Request *RetrieveConversationApiRequest `thrift:"request,1"`
|
||||
}
|
||||
|
||||
func NewConversationServiceRetrieveConversationApiArgs() *ConversationServiceRetrieveConversationApiArgs {
|
||||
return &ConversationServiceRetrieveConversationApiArgs{}
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiArgs) InitDefault() {
|
||||
}
|
||||
|
||||
var ConversationServiceRetrieveConversationApiArgs_Request_DEFAULT *RetrieveConversationApiRequest
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiArgs) GetRequest() (v *RetrieveConversationApiRequest) {
|
||||
if !p.IsSetRequest() {
|
||||
return ConversationServiceRetrieveConversationApiArgs_Request_DEFAULT
|
||||
}
|
||||
return p.Request
|
||||
}
|
||||
|
||||
var fieldIDToName_ConversationServiceRetrieveConversationApiArgs = map[int16]string{
|
||||
1: "request",
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiArgs) IsSetRequest() bool {
|
||||
return p.Request != nil
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiArgs) 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_ConversationServiceRetrieveConversationApiArgs[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 *ConversationServiceRetrieveConversationApiArgs) ReadField1(iprot thrift.TProtocol) error {
|
||||
_field := NewRetrieveConversationApiRequest()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Request = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiArgs) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveConversationApi_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 *ConversationServiceRetrieveConversationApiArgs) 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 *ConversationServiceRetrieveConversationApiArgs) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("ConversationServiceRetrieveConversationApiArgs(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
type ConversationServiceRetrieveConversationApiResult struct {
|
||||
Success *RetrieveConversationApiResponse `thrift:"success,0,optional"`
|
||||
}
|
||||
|
||||
func NewConversationServiceRetrieveConversationApiResult() *ConversationServiceRetrieveConversationApiResult {
|
||||
return &ConversationServiceRetrieveConversationApiResult{}
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiResult) InitDefault() {
|
||||
}
|
||||
|
||||
var ConversationServiceRetrieveConversationApiResult_Success_DEFAULT *RetrieveConversationApiResponse
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiResult) GetSuccess() (v *RetrieveConversationApiResponse) {
|
||||
if !p.IsSetSuccess() {
|
||||
return ConversationServiceRetrieveConversationApiResult_Success_DEFAULT
|
||||
}
|
||||
return p.Success
|
||||
}
|
||||
|
||||
var fieldIDToName_ConversationServiceRetrieveConversationApiResult = map[int16]string{
|
||||
0: "success",
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiResult) IsSetSuccess() bool {
|
||||
return p.Success != nil
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiResult) 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_ConversationServiceRetrieveConversationApiResult[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 *ConversationServiceRetrieveConversationApiResult) ReadField0(iprot thrift.TProtocol) error {
|
||||
_field := NewRetrieveConversationApiResponse()
|
||||
if err := _field.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Success = _field
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ConversationServiceRetrieveConversationApiResult) Write(oprot thrift.TProtocol) (err error) {
|
||||
var fieldId int16
|
||||
if err = oprot.WriteStructBegin("RetrieveConversationApi_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 *ConversationServiceRetrieveConversationApiResult) 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 *ConversationServiceRetrieveConversationApiResult) String() string {
|
||||
if p == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("ConversationServiceRetrieveConversationApiResult(%+v)", *p)
|
||||
|
||||
}
|
||||
|
||||
@ -462,6 +462,7 @@ func Register(r *server.Hertz) {
|
||||
{
|
||||
_conversation0 := _v1.Group("/conversation", _conversation0Mw()...)
|
||||
_conversation0.POST("/create", append(_createconversationMw(), coze.CreateConversation)...)
|
||||
_conversation0.GET("/retrieve", append(_retrieveconversationapiMw(), coze.RetrieveConversationApi)...)
|
||||
{
|
||||
_message := _conversation0.Group("/message", _messageMw()...)
|
||||
_message.POST("/list", append(_getapimessagelistMw(), coze.GetApiMessageList)...)
|
||||
|
||||
@ -1634,3 +1634,8 @@ func _savebasicconfigurationMw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
func _retrieveconversationapiMw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -291,3 +291,37 @@ func (c *ConversationApplicationService) UpdateConversation(ctx context.Context,
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *ConversationApplicationService) RetrieveConversation(ctx context.Context, req *conversation.RetrieveConversationApiRequest) (*conversation.RetrieveConversationApiResponse, error) {
|
||||
resp := new(conversation.RetrieveConversationApiResponse)
|
||||
convID := req.GetConversationID()
|
||||
|
||||
apiKeyInfo := ctxutil.GetApiAuthFromCtx(ctx)
|
||||
userID := apiKeyInfo.UserID
|
||||
|
||||
if userID == 0 {
|
||||
return resp, errorx.New(errno.ErrConversationPermissionCode, errorx.KV("msg", "permission check failed"))
|
||||
}
|
||||
|
||||
conversationDO, err := c.ConversationDomainSVC.GetByID(ctx, convID)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
if conversationDO == nil {
|
||||
return resp, errorx.New(errno.ErrConversationNotFound)
|
||||
}
|
||||
if conversationDO.CreatorID != userID {
|
||||
return resp, errorx.New(errno.ErrConversationNotFound, errorx.KV("msg", "user not match"))
|
||||
}
|
||||
|
||||
resp.ConversationData = &conversation.ConversationData{
|
||||
Id: conversationDO.ID,
|
||||
LastSectionID: &conversationDO.SectionID,
|
||||
ConnectorID: &conversationDO.ConnectorID,
|
||||
CreatedAt: conversationDO.CreatedAt / 1000,
|
||||
Name: ptr.Of(conversationDO.Name),
|
||||
CreatorID: &conversationDO.CreatorID,
|
||||
MetaData: parseExt(conversationDO.Ext),
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -387,6 +387,7 @@ func buildARSM2ApiMessage(chunk *entity.AgentRunResponse) []byte {
|
||||
ChatID: strconv.FormatInt(chunkMessageItem.RunID, 10),
|
||||
ReasoningContent: chunkMessageItem.ReasoningContent,
|
||||
CreatedAt: ptr.Of(chunkMessageItem.CreatedAt / 1000),
|
||||
SectionID: ptr.Of(strconv.FormatInt(chunkMessageItem.SectionID, 10)),
|
||||
}
|
||||
|
||||
mCM, _ := json.Marshal(chunkMessage)
|
||||
|
||||
Reference in New Issue
Block a user