feat(dingtalk): stabilize multimodal answer workflows
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package questiontable
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
@@ -23,14 +24,15 @@ const (
|
||||
|
||||
// Row holds the data needed to produce a Notable v1 typed record.
|
||||
type Row struct {
|
||||
Question string
|
||||
Answer string
|
||||
AskedTime time.Time
|
||||
AskerName string
|
||||
AskerUnionID string
|
||||
TriggerPerson string
|
||||
Department string
|
||||
Region string
|
||||
Question string
|
||||
Answer string
|
||||
AskedTime time.Time
|
||||
AskerName string
|
||||
AskerUnionID string
|
||||
TriggerPerson string
|
||||
Department string
|
||||
Region string
|
||||
QuestionImageURLs []string
|
||||
}
|
||||
|
||||
// ToFields returns a typed field-ID → value map suitable for the Notable v1
|
||||
@@ -67,8 +69,8 @@ func (r Row) ToFields() map[string]interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
// OriginalQuestion.
|
||||
fields[FieldOriginalQuestion] = sanitise(r.Question)
|
||||
// OriginalQuestion: include image marker and stable URLs for image turns.
|
||||
fields[FieldOriginalQuestion] = sanitise(questionWithImageURLs(r.Question, r.QuestionImageURLs))
|
||||
|
||||
// Language.
|
||||
fields[FieldLanguage] = sanitise(lang)
|
||||
@@ -134,3 +136,28 @@ func sanitise(s string) string {
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// questionWithImageURLs prefixes an image marker and renders the stable image
|
||||
// URLs as markdown image syntax when the turn carried image input. Markdown
|
||||
// image syntax lets the Notable cell preview the image (same as the answer
|
||||
// column); a plain-text URL would render as an unpreviewable link.
|
||||
func questionWithImageURLs(question string, imageURLs []string) string {
|
||||
if len(imageURLs) == 0 {
|
||||
return question
|
||||
}
|
||||
var builder strings.Builder
|
||||
builder.WriteString("[图片] ")
|
||||
builder.WriteString(strings.TrimSpace(question))
|
||||
for index, imageURL := range imageURLs {
|
||||
imageURL = strings.TrimSpace(imageURL)
|
||||
if imageURL == "" {
|
||||
continue
|
||||
}
|
||||
builder.WriteString("\n
|
||||
builder.WriteString(imageURL)
|
||||
builder.WriteString(")")
|
||||
}
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user