setMemoryProfile applies a "key=value" (or "key: value") profile update via /memory profile set.
(rest string)
| 319 | // setMemoryProfile applies a "key=value" (or "key: value") profile update |
| 320 | // via /memory profile set. |
| 321 | func (cli *ChatCLI) setMemoryProfile(rest string) { |
| 322 | key, value, ok := splitProfileKV(rest) |
| 323 | if !ok { |
| 324 | fmt.Println(colorize(" "+i18n.T("mem.cmd.profile.set.usage"), ColorGray)) |
| 325 | return |
| 326 | } |
| 327 | changed := cli.memoryStore.UpdateProfile(map[string]string{key: value}) |
| 328 | if cli.contextBuilder != nil { |
| 329 | cli.contextBuilder.InvalidateCache() |
| 330 | } |
| 331 | if changed { |
| 332 | fmt.Printf(" %s %s\n", colorize("OK", ColorGreen), i18n.T("mem.cmd.profile.set.ok", key)) |
| 333 | } else { |
| 334 | fmt.Printf(" %s %s\n", colorize("!", ColorYellow), i18n.T("mem.cmd.profile.set.nochange")) |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | // splitProfileKV splits "key=value" or "key: value" into its parts. |
| 339 | func splitProfileKV(s string) (key, value string, ok bool) { |
no test coverage detected