ParseChatWorkspaceTTL parses a stored TTL string, returning the default when the value is empty.
(s string)
| 1053 | // ParseChatWorkspaceTTL parses a stored TTL string, returning the |
| 1054 | // default when the value is empty. |
| 1055 | func ParseChatWorkspaceTTL(s string) (time.Duration, error) { |
| 1056 | if s == "" { |
| 1057 | return DefaultChatWorkspaceTTL, nil |
| 1058 | } |
| 1059 | d, err := time.ParseDuration(s) |
| 1060 | if err != nil { |
| 1061 | return 0, xerrors.Errorf("invalid duration %q: %w", s, err) |
| 1062 | } |
| 1063 | if d < 0 { |
| 1064 | return 0, xerrors.New("duration must be non-negative") |
| 1065 | } |
| 1066 | return d, nil |
| 1067 | } |
| 1068 | |
| 1069 | // ChatTemplateAllowlist is the request and response body for the |
| 1070 | // chat template allowlist configuration endpoint. An empty list |