mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
refactor(core): codebase quality cleanup
- Remove user-level model settings (chat_model_id, memory_model_id, embedding_model_id, max_context_load_time, language) from users table - Merge migration 0002 into 0001, remove compatibility migrations - Delete dead conversation/resolver.go (1177 lines, only flow/resolver.go used) - Remove type aliases (Chat=Conversation, types_alias.go) - Fix SQL: remove AND false stub, fix UpdateChatTitle model_id, reset model IDs in DeleteSettings, add preauth expiry filter, add ListMessages limit, remove 10 dead queries - Extract shared handler helpers (RequireChannelIdentityID, AuthorizeBotAccess) - Rename internal/router to internal/channel/inbound - Fix identity confusion: remove UserID->ChannelIdentityID fallbacks - Fix all _ = var patterns with proper error logging - Fix error propagation: storeMessages, rescheduleJob, botContainerID - Fix naming: ModelId->ModelID, active->is_active, Duration semantic fix - Remove dead code: mcpService, ReplyTarget, callMCPServer, sshShellQuote, buildSessionMetadata, ChatRequest.Language, TriggerPayload.ChatID - Fix code quality: errors.Is(), remove goto, CreateHuman deprecated - Remove Enable model endpoint and user-level settings CLI commands - Regenerate sqlc, swagger, SDK
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package flow
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/memohai/memoh/internal/conversation"
|
||||
)
|
||||
|
||||
// ExtractAssistantOutputs collects assistant-role outputs from a slice of ModelMessages.
|
||||
func ExtractAssistantOutputs(messages []ModelMessage) []AssistantOutput {
|
||||
func ExtractAssistantOutputs(messages []conversation.ModelMessage) []conversation.AssistantOutput {
|
||||
if len(messages) == 0 {
|
||||
return nil
|
||||
}
|
||||
outputs := make([]AssistantOutput, 0, len(messages))
|
||||
outputs := make([]conversation.AssistantOutput, 0, len(messages))
|
||||
for _, msg := range messages {
|
||||
if msg.Role != "assistant" {
|
||||
continue
|
||||
@@ -17,16 +21,16 @@ func ExtractAssistantOutputs(messages []ModelMessage) []AssistantOutput {
|
||||
if content == "" && len(parts) == 0 {
|
||||
continue
|
||||
}
|
||||
outputs = append(outputs, AssistantOutput{Content: content, Parts: parts})
|
||||
outputs = append(outputs, conversation.AssistantOutput{Content: content, Parts: parts})
|
||||
}
|
||||
return outputs
|
||||
}
|
||||
|
||||
func filterContentParts(parts []ContentPart) []ContentPart {
|
||||
func filterContentParts(parts []conversation.ContentPart) []conversation.ContentPart {
|
||||
if len(parts) == 0 {
|
||||
return nil
|
||||
}
|
||||
filtered := make([]ContentPart, 0, len(parts))
|
||||
filtered := make([]conversation.ContentPart, 0, len(parts))
|
||||
for _, p := range parts {
|
||||
if p.HasValue() {
|
||||
filtered = append(filtered, p)
|
||||
|
||||
Reference in New Issue
Block a user