fix(text): fix resolve emoji shown in telegram stream mode (#261)

* fix(text): resolve emoji shown in telegram stream mode

* chore(text): removing "reasoing" types in plain msg.

* feat(conversation): add function to check for tool call content in assistant outputs
This commit is contained in:
MoeMagicMango
2026-03-18 15:19:50 +08:00
committed by GitHub
parent 76a90191b4
commit ebf238a568
3 changed files with 28 additions and 3 deletions
+4 -3
View File
@@ -401,10 +401,11 @@ func (s *telegramOutboundStream) pushFinal(ctx context.Context, event channel.St
msg := event.Final.Message
finalText := bufText
if finalText == "" && !s.isPrivateChat {
finalText = strings.TrimSpace(msg.PlainText())
if authoritative := strings.TrimSpace(msg.PlainText()); authoritative != "" {
if !s.isPrivateChat || bufText != "" {
finalText = authoritative
}
}
// Convert markdown to Telegram HTML for the final message.
formatted, pm := formatTelegramOutput(finalText, msg.Format)
if pm != "" {
@@ -16,6 +16,10 @@ func ExtractAssistantOutputs(messages []conversation.ModelMessage) []conversatio
if msg.Role != "assistant" {
continue
}
// skip tool call tips content.
if hasToolCallContent(msg) {
continue
}
content := strings.TrimSpace(msg.TextContent())
parts := filterContentParts(msg.ContentParts())
if content == "" && len(parts) == 0 {
@@ -26,12 +30,28 @@ func ExtractAssistantOutputs(messages []conversation.ModelMessage) []conversatio
return outputs
}
func hasToolCallContent(msg conversation.ModelMessage) bool {
if len(msg.ToolCalls) > 0 {
return true
}
for _, p := range msg.ContentParts() {
if p.Type == "tool-call" {
return true
}
}
return false
}
func filterContentParts(parts []conversation.ContentPart) []conversation.ContentPart {
if len(parts) == 0 {
return nil
}
filtered := make([]conversation.ContentPart, 0, len(parts))
for _, p := range parts {
// Ignore Reasoning parts
if p.Type == "reasoning" {
continue
}
if p.HasValue() {
filtered = append(filtered, p)
}
+4
View File
@@ -115,6 +115,10 @@ func (m ModelMessage) TextContent() string {
if err := json.Unmarshal(m.Content, &parts); err == nil {
texts := make([]string, 0, len(parts))
for _, p := range parts {
// Ignore Reasoning parts
if p.Type == "reasoning" {
continue
}
if strings.TrimSpace(p.Text) != "" {
texts = append(texts, p.Text)
}