Elffuss BraidHub

kikocis/llama-stack public

main · 506 BRawPermalink
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the terms described in the LICENSE file in
5# the root directory of this source tree.
6
7import json
8from datetime import datetime
9from enum import Enum
10
11
12class EnumEncoder(json.JSONEncoder):
13 def default(self, obj):
14 if isinstance(obj, Enum):
15 return obj.value
16 elif isinstance(obj, datetime):
17 return obj.isoformat()
18 return super().default(obj)