package model type ListItem struct { Title string `json:"title"` TextContent string `json:"textContent"` Audio struct { Stream struct { Url string `json:"url"` } `json:"stream"` } `json:"audio"` MediaId string `json:"mediaId"` SelfData string `json:"selfData"` } type TencentNlpResp struct { Header *struct { RequestID string `json:"RequestID"` SessionID string `json:"SessionID"` DialogID string `json:"DialogID"` Code int `json:"Code"` Message string `json:"Message"` } `json:"Header"` Payload *struct { Semantic *struct { Query string `json:"Query"` SessionStatus int `json:"SessionStatus"` TurnType string `json:"TurnType"` Results []struct { Nlu *struct { Domain string `json:"Domain"` Intent string `json:"Intent"` // Slots []struct { // Name string `json:"Name"` // Value string `json:"Value"` // RawValue string `json:"RawValue"` // Type string `json:"Type"` // } `json:"Slots"` Slots []map[string]interface{} `json:"Slots"` Confidence float32 `json:"Confidence"` } `json:"Nlu"` Dm *struct { SessionID string `json:"SessionID"` Text string `json:"Text"` Skill *struct { Version string `json:"Version"` ExecutionOrder string `json:"ExecutionOrder"` AskCount int `json:"AskCount"` CacheTTS int `json:"CacheTTS"` Operation struct { Control struct { Name string `json:"Name"` Param interface{} `json:"Param"` } `json:"Control"` } `json:"Operation"` Widget *struct { Name string `json:"Name"` Type string `json:"Type"` Data *struct { ControlInfo *struct { Version string `json:"version"` Type string `json:"type"` TextSpeak string `json:"textSpeak"` } `json:"controlInfo"` GlobalInfo struct { BackgroundImage interface{} `json:"backgroundImage"` SeeMore string `json:"seeMore"` } `json:"globalInfo"` ListItems []ListItem `json:"listItems"` } `json:"Data"` Recommend interface{} `json:"Recommend"` } `json:"Widget"` Command map[string]interface{} `json:"Command"` // Command struct { // Name string `json:"Name"` // Param interface{} `json:"Param"` // TextList interface{} `json:"TextList"` // Inner interface{} `json:"Inner"` // } `json:"Command"` } `json:"Skill"` IsLocalEntity int `json:"IsLocalEntity"` SessionComplete int `json:"SessionComplete"` } `json:"Dm"` Status struct { Code int `json:"Code"` Msg string `json:"Msg"` } `json:"Status"` } `json:"Results"` } `json:"Semantic"` } `json:"Payload"` } func (this *TencentNlpResp) CheckHeader() bool { if this.Header == nil { return false } return true } func (this *TencentNlpResp) CheckPayload() bool { if this.Payload == nil { return false } return true } func (this *TencentNlpResp) CheckSemantic() bool { if !this.CheckPayload() || this.Payload.Semantic == nil { return false } return true } func (this *TencentNlpResp) CheckResults() bool { if !this.CheckSemantic() || len(this.Payload.Semantic.Results) == 0 { return false } return true } func (this *TencentNlpResp) CheckNlu() bool { if !this.CheckResults() || this.Payload.Semantic.Results[0].Nlu == nil { return false } return true } func (this *TencentNlpResp) CheckDm() bool { if !this.CheckResults() || this.Payload.Semantic.Results[0].Dm == nil { return false } return true } func (this *TencentNlpResp) CheckSkill() bool { if !this.CheckDm() || this.Payload.Semantic.Results[0].Dm.Skill == nil { return false } return true } func (this *TencentNlpResp) CheckWidget() bool { if !this.CheckDm() || this.Payload.Semantic.Results[0].Dm.Skill.Widget == nil { return false } return true } func (this *TencentNlpResp) CheckWidgetData() bool { if !this.CheckWidget() || this.Payload.Semantic.Results[0].Dm.Skill.Widget.Data == nil { return false } return true } func (this *TencentNlpResp) CheckControlInfo() bool { if !this.CheckWidgetData() || this.Payload.Semantic.Results[0].Dm.Skill.Widget.Data.ControlInfo == nil { return false } return true } func (this *TencentNlpResp) GetCode() int { return this.Header.Code } func (this *TencentNlpResp) GetMessage() string { return this.Header.Message } func (this *TencentNlpResp) GetDomain() string { return this.Payload.Semantic.Results[0].Nlu.Domain } func (this *TencentNlpResp) GetIntent() string { return this.Payload.Semantic.Results[0].Nlu.Intent } func (this *TencentNlpResp) GetSessionComplete() int { return this.Payload.Semantic.Results[0].Dm.SessionComplete } func (this *TencentNlpResp) GetSessionID() string { return this.Header.SessionID } func (this *TencentNlpResp) GetListItems() []ListItem { return this.Payload.Semantic.Results[0].Dm.Skill.Widget.Data.ListItems } func (this *TencentNlpResp) GetSlots() []map[string]interface{} { return this.Payload.Semantic.Results[0].Nlu.Slots } func (this *TencentNlpResp) GetText() string { return this.Payload.Semantic.Results[0].Dm.Text } func (this *TencentNlpResp) GetType() string { return this.Payload.Semantic.Results[0].Dm.Skill.Widget.Data.ControlInfo.Type } func (this *TencentNlpResp) GetCommand() map[string]interface{} { return this.Payload.Semantic.Results[0].Dm.Skill.Command } type Command struct { Name string `json:"Name"` Param map[string]string `json:"Param"` TextList []struct { Status string `json:"Status"` Text string `json:"Text"` PlaceholderList []string `json:"PlaceholderList"` } `json:"TextList"` Inner interface{} `json:"Inner"` } type TencentNlpWsRespNative struct { Name string `json:"Name"` SeqID string `json:"SeqID"` Timeout int `json:"Timeout"` Param map[string]string `json:"Param"` } // wss 返回结果 type TencentNlpWsResp struct { Header *struct { RequestID string `json:"RequestID"` DialogID string `json:"DialogID"` Code int `json:"Code"` Message string `json:"Message"` } `json:"Header"` Payload *struct { ResponseType string `json:"ResponseType"` Data *struct { Class string `json:"Class"` AssistantStatus string `json:"AssistantStatus"` // VirtualMan string `json:"VirtualMan"` // TODO: object类型, 说明文档错误 Semantic *struct { Query string `json:"Query"` RewrittenQuery string `json:"RewrittenQuery"` SessionStatus int `json:"SessionStatus"` TurnType string `json:"TurnType"` IsNeedShield int `json:"IsNeedShield"` Inner struct { SegmentID int `json:"SegmentID"` IsNeedShield int `json:"IsNeedShield"` // CompoundQuery.IsCompoundQuery // TODO: 说明文档中有, 实际返回缺失该字段 // CompoundQuery.Confidence // TODO: 说明文档中有, 实际返回缺失该字段 } `json:"Inner"` Results []struct { Nlu *struct { Domain string `json:"Domain"` Intent string `json:"Intent"` IsNeedShield int `json:"IsNeedShield"` Inner struct { SessionComplete int `json:"SessionComplete"` Confidence float32 `json:"Confidence"` IsLocalEntity int `json:"IsLocalEntity"` IsNeedShield int `json:"IsNeedShield"` } `json:"Inner"` Slots []map[string]interface{} `json:"Slots"` // Confidence float32 `json:"Confidence"` } `json:"Nlu"` Dm *struct { SessionID string `json:"SessionID"` Text string `json:"Text"` Skill *struct { Version string `json:"Version"` ExecutionOrder string `json:"ExecutionOrder"` AskCount int `json:"AskCount"` CacheTTS int `json:"CacheTTS"` Operation struct { Control struct { Name string `json:"Name"` Param interface{} `json:"Param"` } `json:"Control"` } `json:"Operation"` Widget *struct { Name string `json:"Name"` Type string `json:"Type"` Data *struct { ControlInfo *struct { Version string `json:"version"` Type string `json:"type"` TextSpeak string `json:"textSpeak"` } `json:"controlInfo"` GlobalInfo struct { BackgroundImage interface{} `json:"backgroundImage"` SeeMore string `json:"seeMore"` } `json:"globalInfo"` ListItems []ListItem `json:"listItems"` } `json:"Data"` Recommend interface{} `json:"Recommend"` } `json:"Widget"` // Command map[string]interface{} `json:"Command"` Command Command `json:"Command"` } `json:"Skill"` IsLocalEntity int `json:"IsLocalEntity"` SessionComplete int `json:"SessionComplete"` // TODO: 无该字段 } `json:"Dm"` Status struct { Code int `json:"Code"` Msg string `json:"Msg"` } `json:"Status"` } `json:"Results"` } `json:"Semantic"` // SemanticID // TODO: 说明文档缺少该字段的说明 Native *TencentNlpWsRespNative `json:"Native"` } `json:"Data"` CommType string `json:"CommType"` SDKExtend struct { } `json:"SDKExtend"` } `json:"Payload"` } func (this *TencentNlpWsResp) CheckHeader() bool { if this.Header == nil { return false } return true } func (this *TencentNlpWsResp) CheckPayload() bool { if this.Payload == nil { return false } return true } func (this *TencentNlpWsResp) CheckData() bool { if !this.CheckPayload() || this.Payload.Data == nil { return false } return true } func (this *TencentNlpWsResp) CheckNative() bool { if !this.CheckData() || this.Payload.Data.Native == nil { return false } return true } func (this *TencentNlpWsResp) CheckSemantic() bool { if !this.CheckData() || this.Payload.Data.Semantic == nil { return false } return true } func (this *TencentNlpWsResp) CheckResults() bool { if !this.CheckSemantic() || len(this.Payload.Data.Semantic.Results) == 0 { return false } return true } func (this *TencentNlpWsResp) CheckNlu() bool { if !this.CheckResults() || this.Payload.Data.Semantic.Results[0].Nlu == nil { return false } return true } func (this *TencentNlpWsResp) CheckDm() bool { if !this.CheckResults() || this.Payload.Data.Semantic.Results[0].Dm == nil { return false } return true } func (this *TencentNlpWsResp) CheckSkill() bool { if !this.CheckDm() || this.Payload.Data.Semantic.Results[0].Dm.Skill == nil { return false } return true } func (this *TencentNlpWsResp) CheckWidget() bool { if !this.CheckDm() || this.Payload.Data.Semantic.Results[0].Dm.Skill.Widget == nil { return false } return true } func (this *TencentNlpWsResp) CheckWidgetData() bool { if !this.CheckWidget() || this.Payload.Data.Semantic.Results[0].Dm.Skill.Widget.Data == nil { return false } return true } func (this *TencentNlpWsResp) CheckControlInfo() bool { if !this.CheckWidgetData() || this.Payload.Data.Semantic.Results[0].Dm.Skill.Widget.Data.ControlInfo == nil { return false } return true } func (this *TencentNlpWsResp) GetCode() int { return this.Header.Code } func (this *TencentNlpWsResp) GetMessage() string { return this.Header.Message } func (this *TencentNlpWsResp) GetDomain() string { return this.Payload.Data.Semantic.Results[0].Nlu.Domain } func (this *TencentNlpWsResp) GetIntent() string { return this.Payload.Data.Semantic.Results[0].Nlu.Intent } func (this *TencentNlpWsResp) GetSessionComplete() int { return this.Payload.Data.Semantic.Results[0].Dm.SessionComplete } func (this *TencentNlpWsResp) GetListItems() []ListItem { return this.Payload.Data.Semantic.Results[0].Dm.Skill.Widget.Data.ListItems } func (this *TencentNlpWsResp) GetSlots() []map[string]interface{} { return this.Payload.Data.Semantic.Results[0].Nlu.Slots } func (this *TencentNlpWsResp) GetText() string { return this.Payload.Data.Semantic.Results[0].Dm.Text } func (this *TencentNlpWsResp) GetType() string { return this.Payload.Data.Semantic.Results[0].Dm.Skill.Widget.Data.ControlInfo.Type } func (this *TencentNlpWsResp) GetCommand() Command { return this.Payload.Data.Semantic.Results[0].Dm.Skill.Command } func (this *TencentNlpWsResp) GetQuery() string { return this.Payload.Data.Semantic.Query } func (this *TencentNlpWsResp) GetResponseType() string { return this.Payload.ResponseType } func (this *TencentNlpWsResp) GetClass() string { return this.Payload.Data.Class } func (this *TencentNlpWsResp) GetNativate() *TencentNlpWsRespNative { return this.Payload.Data.Native } func (this *TencentNlpWsResp) GetSessionStatus() int { return this.Payload.Data.Semantic.SessionStatus }