refactor: refactor server as a package
This commit is contained in:
1 parent
75e49fcbcd
commit
e1063fc733
5 files changed
+375
-364
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import json
|
||||
|
||||
from stream import Stream
|
||||
from tool import ToolSpec
|
||||
|
||||
def encode_json(value):
|
||||
def encode_unknown(value):
|
||||
if isinstance(value, ToolSpec):
|
||||
return value.to_openai_dict()
|
||||
elif isinstance(value, Stream):
|
||||
return {'streamId': value.id}
|
||||
else:
|
||||
return repr(value)
|
||||
return json.dumps(value, default=encode_unknown)
|
||||
Reference in new issue
Block a user