mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
feat(chat,seahorse): persist and display model_name across history (#2897)
* feat(chat,seahorse): persist and display model_name across history * test(seahorse): fix lint regressions in repair coverage * fix(pico): preserve model_name in live updates * fix(pico): preserve model_name through live stream wrappers
This commit is contained in:
@@ -96,15 +96,46 @@ func markFinalOutbound(msg *bus.OutboundMessage) {
|
||||
msg.Context.Raw[metadataKeyOutboundKind] = outboundKindFinal
|
||||
}
|
||||
|
||||
func outboundMessageForTurnWithKind(ts *turnState, content, kind string) bus.OutboundMessage {
|
||||
type outboundTurnMessageOptions struct {
|
||||
kind string
|
||||
modelName string
|
||||
raw map[string]string
|
||||
}
|
||||
|
||||
func outboundMessageForTurnWithOptions(
|
||||
ts *turnState,
|
||||
content string,
|
||||
opts outboundTurnMessageOptions,
|
||||
) bus.OutboundMessage {
|
||||
msg := outboundMessageForTurn(ts, content)
|
||||
if strings.TrimSpace(kind) == "" {
|
||||
trimmedKind := strings.TrimSpace(opts.kind)
|
||||
trimmedModelName := strings.TrimSpace(opts.modelName)
|
||||
rawCount := len(opts.raw)
|
||||
if trimmedKind != "" {
|
||||
rawCount++
|
||||
}
|
||||
if trimmedModelName != "" {
|
||||
rawCount++
|
||||
}
|
||||
if rawCount == 0 {
|
||||
return msg
|
||||
}
|
||||
|
||||
if msg.Context.Raw == nil {
|
||||
msg.Context.Raw = make(map[string]string, 1)
|
||||
msg.Context.Raw = make(map[string]string, rawCount)
|
||||
}
|
||||
if trimmedKind != "" {
|
||||
msg.Context.Raw[metadataKeyMessageKind] = trimmedKind
|
||||
}
|
||||
if trimmedModelName != "" {
|
||||
msg.Context.Raw["model_name"] = trimmedModelName
|
||||
}
|
||||
for key, value := range opts.raw {
|
||||
if strings.TrimSpace(key) == "" {
|
||||
continue
|
||||
}
|
||||
msg.Context.Raw[key] = value
|
||||
}
|
||||
msg.Context.Raw[metadataKeyMessageKind] = kind
|
||||
return msg
|
||||
}
|
||||
|
||||
@@ -521,8 +552,9 @@ func hasMediaRefs(messages []providers.Message) bool {
|
||||
|
||||
func sideQuestionModelName(agent *AgentInstance, usedLight bool) string {
|
||||
if usedLight && len(agent.LightCandidates) > 0 {
|
||||
// Use the first light candidate's model
|
||||
return agent.LightCandidates[0].Model
|
||||
if name := resolvedCandidateModelName(agent.LightCandidates, ""); name != "" {
|
||||
return name
|
||||
}
|
||||
}
|
||||
return agent.Model
|
||||
}
|
||||
@@ -538,6 +570,14 @@ func modelNameFromIdentityKey(identityKey string) string {
|
||||
return identityKey
|
||||
}
|
||||
|
||||
func modelAliasFromCandidateIdentityKey(identityKey string) string {
|
||||
const prefix = "model_name:"
|
||||
if !strings.HasPrefix(identityKey, prefix) {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(strings.TrimPrefix(identityKey, prefix))
|
||||
}
|
||||
|
||||
func closeProviderIfStateful(provider providers.LLMProvider) {
|
||||
if stateful, ok := provider.(providers.StatefulProvider); ok {
|
||||
stateful.Close()
|
||||
|
||||
Reference in New Issue
Block a user