neon-data-models 0.0.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neon_data_models/__init__.py +25 -0
- neon_data_models/enum.py +83 -0
- neon_data_models/models/__init__.py +25 -0
- neon_data_models/models/api/__init__.py +28 -0
- neon_data_models/models/api/mq.py +40 -0
- neon_data_models/models/api/node_v1/__init__.py +155 -0
- neon_data_models/models/base/__init__.py +33 -0
- neon_data_models/models/base/contexts.py +98 -0
- neon_data_models/models/base/messagebus.py +65 -0
- neon_data_models/models/client/__init__.py +27 -0
- neon_data_models/models/client/node.py +69 -0
- neon_data_models/models/user/__init__.py +28 -0
- neon_data_models/models/user/database.py +162 -0
- neon_data_models/models/user/neon_profile.py +167 -0
- neon_data_models/util.py +52 -0
- neon_data_models/version.py +29 -0
- neon_data_models-0.0.0a1.dist-info/LICENSE.md +21 -0
- neon_data_models-0.0.0a1.dist-info/METADATA +48 -0
- neon_data_models-0.0.0a1.dist-info/RECORD +22 -0
- neon_data_models-0.0.0a1.dist-info/WHEEL +5 -0
- neon_data_models-0.0.0a1.dist-info/top_level.txt +1 -0
- neon_data_models-0.0.0a1.dist-info/zip-safe +1 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
neon_data_models/enum.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from enum import IntEnum
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AccessRoles(IntEnum):
|
|
31
|
+
"""
|
|
32
|
+
Defines access roles such that a larger value always corresponds to more
|
|
33
|
+
permissions. `0` equates to no permission, negative numbers correspond to
|
|
34
|
+
non-user roles. In this way, an activity can require, for example,
|
|
35
|
+
`permission > AccessRoles.GUEST` to grant access to all registered users,
|
|
36
|
+
admins, and owners.
|
|
37
|
+
"""
|
|
38
|
+
NONE = 0
|
|
39
|
+
GUEST = 1
|
|
40
|
+
USER = 2
|
|
41
|
+
ADMIN = 3
|
|
42
|
+
OWNER = 4
|
|
43
|
+
|
|
44
|
+
NODE = -1
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class UserData(IntEnum):
|
|
48
|
+
"""
|
|
49
|
+
Defines types of user data.
|
|
50
|
+
"""
|
|
51
|
+
CACHES = 0
|
|
52
|
+
PROFILE = 1
|
|
53
|
+
TRANSCRIPTS = 2
|
|
54
|
+
LIKED_BRANDS = 3
|
|
55
|
+
DISLIKED_BRANDS = 4
|
|
56
|
+
ALL_DATA = 5
|
|
57
|
+
ALL_MEDIA = 6
|
|
58
|
+
UNITS_CONFIG = 7
|
|
59
|
+
LANGUAGE_CONFIG = 8
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AlertType(IntEnum):
|
|
63
|
+
"""
|
|
64
|
+
Defines kinds of alerts.
|
|
65
|
+
"""
|
|
66
|
+
ALL = -1
|
|
67
|
+
ALARM = 0
|
|
68
|
+
TIMER = 1
|
|
69
|
+
REMINDER = 2
|
|
70
|
+
UNKNOWN = 99
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class Weekdays(IntEnum):
|
|
74
|
+
"""
|
|
75
|
+
Defines weekdays as used in the Alerts skill.
|
|
76
|
+
"""
|
|
77
|
+
MON = 0
|
|
78
|
+
TUE = 1
|
|
79
|
+
WED = 2
|
|
80
|
+
THU = 3
|
|
81
|
+
FRI = 4
|
|
82
|
+
SAT = 5
|
|
83
|
+
SUN = 6
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from neon_data_models.models.api.node_v1 import *
|
|
28
|
+
from neon_data_models.models.api.mq import *
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from typing import Literal, Optional
|
|
28
|
+
from neon_data_models.models.base.contexts import MQContext
|
|
29
|
+
from neon_data_models.models.user.database import User
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class UserDbRequest(MQContext):
|
|
33
|
+
operation: Literal["create", "read", "update", "delete"]
|
|
34
|
+
username: str
|
|
35
|
+
password: Optional[str] = None
|
|
36
|
+
access_token: Optional[str] = None
|
|
37
|
+
user: Optional[User] = None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
__all__ = [UserDbRequest.__name__]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from datetime import datetime, timedelta
|
|
28
|
+
from pydantic import Field
|
|
29
|
+
from typing import List, Literal, Optional, Annotated, Dict
|
|
30
|
+
|
|
31
|
+
from neon_data_models.enum import UserData, AlertType, Weekdays
|
|
32
|
+
from neon_data_models.models.base import BaseModel
|
|
33
|
+
from neon_data_models.models.base.messagebus import BaseMessage, MessageContext
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class AudioInputData(BaseModel):
|
|
37
|
+
audio_data: str = Field(description="base64-encoded audio")
|
|
38
|
+
lang: str = Field(description="BCP-47 language code")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class KlatResponse(BaseModel):
|
|
42
|
+
sentence: str = Field(description="Text response")
|
|
43
|
+
audio: Dict[Literal["male", "female"], Optional[str]] = Field(
|
|
44
|
+
description="Mapping of gender to b64-encoded audio")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class AudioInputResponseData(BaseModel):
|
|
48
|
+
parser_data: dict
|
|
49
|
+
transcripts: List[str]
|
|
50
|
+
skills_recv: bool
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class NodeAudioInput(BaseMessage):
|
|
54
|
+
msg_type: Literal["neon.audio_input"] = "neon.audio_input"
|
|
55
|
+
data: AudioInputData
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class NodeTextInput(BaseMessage):
|
|
59
|
+
class UtteranceInputData(BaseModel):
|
|
60
|
+
utterances: List[str] = Field(description="List of input utterance(s)")
|
|
61
|
+
lang: str = Field(description="BCP-47 language")
|
|
62
|
+
|
|
63
|
+
msg_type: Literal["recognizer_loop:utterance"] = "recognizer_loop:utterance"
|
|
64
|
+
data: UtteranceInputData
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class NodeGetStt(BaseMessage):
|
|
68
|
+
msg_type: Literal["neon.get_stt"] = "neon.get_stt"
|
|
69
|
+
data: AudioInputData
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class NodeGetTts(BaseMessage):
|
|
73
|
+
class TextInputData(BaseModel):
|
|
74
|
+
text: str = Field(description="String text input")
|
|
75
|
+
lang: str = Field(description="BCP-47 language code")
|
|
76
|
+
|
|
77
|
+
msg_type: Literal["neon.get_tts"] = "neon.get_tts"
|
|
78
|
+
data: TextInputData
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class NodeKlatResponse(BaseMessage):
|
|
82
|
+
msg_type: Literal["klat.response"] = "klat.response"
|
|
83
|
+
data: Dict[str, KlatResponse] = Field(type=Dict[str, KlatResponse],
|
|
84
|
+
description="dict of BCP-47 language: KlatResponse")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class NodeAudioInputResponse(BaseMessage):
|
|
88
|
+
msg_type: Literal["neon.audio_input.response"] = "neon.audio_input.response"
|
|
89
|
+
data: AudioInputResponseData
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class NodeGetSttResponse(BaseMessage):
|
|
93
|
+
msg_type: Literal["neon.get_stt.response"] = "neon.get_stt.response"
|
|
94
|
+
data: AudioInputResponseData
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class NodeGetTtsResponse(BaseMessage):
|
|
98
|
+
msg_type: Literal["neon.get_tts.response"] = "neon.get_tts.response"
|
|
99
|
+
data: Dict[str, KlatResponse] = (
|
|
100
|
+
Field(type=Dict[str, KlatResponse],
|
|
101
|
+
description="dict of BCP-47 language: KlatResponse"))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class CoreWWDetected(BaseMessage):
|
|
105
|
+
msg_type: Literal["neon.ww_detected"] = "neon.ww_detected"
|
|
106
|
+
# TODO: Define/implement schema in neon-speech service
|
|
107
|
+
data: dict
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class CoreIntentFailure(BaseMessage):
|
|
111
|
+
msg_type: Literal["complete_intent_failure"] = "complete_intent_failure"
|
|
112
|
+
data: dict # Empty dict
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class CoreErrorResponse(BaseMessage):
|
|
116
|
+
class KlatErrorData(BaseModel):
|
|
117
|
+
error: str = "unknown error"
|
|
118
|
+
data: dict = {}
|
|
119
|
+
|
|
120
|
+
msg_type: Literal["klat.error"] = "klat.error"
|
|
121
|
+
data: KlatErrorData
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class CoreClearData(BaseMessage):
|
|
125
|
+
class ClearDataData(BaseModel):
|
|
126
|
+
username: str
|
|
127
|
+
data_to_remove: List[UserData]
|
|
128
|
+
|
|
129
|
+
msg_type: Literal["neon.clear_data"] = "neon.clear_data"
|
|
130
|
+
data: ClearDataData
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class CoreAlertExpired(BaseMessage):
|
|
134
|
+
class AlertData(BaseModel):
|
|
135
|
+
alert_type: AlertType
|
|
136
|
+
priority: Annotated[int, Field(gt=1, lt=10)]
|
|
137
|
+
alert_name: str
|
|
138
|
+
context: MessageContext
|
|
139
|
+
next_expiration_time: Optional[datetime]
|
|
140
|
+
repeat_frequency: Optional[timedelta]
|
|
141
|
+
repeat_days: Optional[List[Weekdays]]
|
|
142
|
+
end_repeat: Optional[datetime]
|
|
143
|
+
audio_file: Optional[str] = None
|
|
144
|
+
script_filename: Optional[str] = None
|
|
145
|
+
|
|
146
|
+
msg_type: Literal["neon.alert_expired"] = "neon.alert_expired"
|
|
147
|
+
data: AlertData
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
__all__ = [NodeAudioInput.__name__, NodeTextInput.__name__, NodeGetStt.__name__,
|
|
151
|
+
NodeGetTts.__name__, NodeKlatResponse.__name__,
|
|
152
|
+
NodeAudioInputResponse.__name__, NodeGetSttResponse.__name__,
|
|
153
|
+
NodeGetTtsResponse.__name__, CoreWWDetected.__name__,
|
|
154
|
+
CoreIntentFailure.__name__, CoreErrorResponse.__name__,
|
|
155
|
+
CoreClearData.__name__, CoreAlertExpired.__name__]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from os import environ
|
|
28
|
+
from pydantic import ConfigDict, BaseModel as _BaseModel
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class BaseModel(_BaseModel):
|
|
32
|
+
model_config = ConfigDict(extra="allow" if environ.get(
|
|
33
|
+
"NEON_DATA_MODELS_ALLOW_EXTRA", "false") != "false" else "ignore")
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
from datetime import datetime, timedelta
|
|
27
|
+
from typing import Literal, List, Optional
|
|
28
|
+
|
|
29
|
+
from pydantic import Field
|
|
30
|
+
|
|
31
|
+
from neon_data_models.models.base import BaseModel
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class SessionContext(BaseModel):
|
|
35
|
+
session_id: str = "default"
|
|
36
|
+
active_skills: List[str] = []
|
|
37
|
+
utterance_states: dict = {}
|
|
38
|
+
lang: Optional[str] = None
|
|
39
|
+
context: dict = {}
|
|
40
|
+
site_id: str = "unknown"
|
|
41
|
+
pipeline: List[str] = []
|
|
42
|
+
location: dict = {}
|
|
43
|
+
system_unit: Optional[Literal["imperial", "metric"]] = None
|
|
44
|
+
date_format: Optional[Literal["MDY", "YMD", "YDM", "DMY"]] = None
|
|
45
|
+
time: Optional[Literal[12, 24]] = None
|
|
46
|
+
is_recording: bool = False
|
|
47
|
+
is_speaking: bool = False
|
|
48
|
+
blacklisted_skills: List[str] = []
|
|
49
|
+
blacklisted_intents: List[str] = []
|
|
50
|
+
|
|
51
|
+
def model_dump(self, *args, **kwargs) -> dict:
|
|
52
|
+
# Override to explicitly exclude default `None` values so that upstream
|
|
53
|
+
# logic works to read values from global config
|
|
54
|
+
kwargs["exclude_none"] = True
|
|
55
|
+
return BaseModel.model_dump(self, *args, **kwargs)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class TimingContext(BaseModel):
|
|
59
|
+
def __init__(self, **kwargs):
|
|
60
|
+
# Enables backwards-compat. with old context values
|
|
61
|
+
if transcribed := kwargs.pop("transcribed", None):
|
|
62
|
+
kwargs.setdefault("handle_utterance", transcribed)
|
|
63
|
+
if text_parsers := kwargs.pop("text_parsers", None):
|
|
64
|
+
kwargs.setdefault("transform_utterance", text_parsers)
|
|
65
|
+
BaseModel.__init__(self, **kwargs)
|
|
66
|
+
|
|
67
|
+
audio_begin: Optional[datetime] = None
|
|
68
|
+
audio_end: Optional[datetime] = None
|
|
69
|
+
client_sent: Optional[datetime] = None
|
|
70
|
+
gradio_sent: Optional[datetime] = None
|
|
71
|
+
handle_utterance: Optional[datetime] = None
|
|
72
|
+
response_sent: Optional[datetime] = None
|
|
73
|
+
speech_start: Optional[datetime] = None
|
|
74
|
+
|
|
75
|
+
get_stt: Optional[timedelta] = None
|
|
76
|
+
get_tts: Optional[timedelta] = None
|
|
77
|
+
iris_input_handling: Optional[timedelta] = None
|
|
78
|
+
mq_response_handler: Optional[timedelta] = None
|
|
79
|
+
mq_from_core: Optional[timedelta] = None
|
|
80
|
+
mq_from_client: Optional[timedelta] = None
|
|
81
|
+
mq_input_handler: Optional[timedelta] = None
|
|
82
|
+
client_to_core: Optional[timedelta] = None
|
|
83
|
+
client_from_core: Optional[timedelta] = None
|
|
84
|
+
save_transcript: Optional[timedelta] = None
|
|
85
|
+
transform_audio: Optional[timedelta] = None
|
|
86
|
+
transform_utterance: Optional[timedelta] = None
|
|
87
|
+
wait_in_queue: Optional[timedelta] = None
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class KlatContext(BaseModel):
|
|
91
|
+
sid: str
|
|
92
|
+
cid: str
|
|
93
|
+
title: Optional[str] = ""
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class MQContext(BaseModel):
|
|
97
|
+
routing_key: Optional[str] = None
|
|
98
|
+
message_id: str
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from typing import Optional, List, Union
|
|
28
|
+
from pydantic import ConfigDict, Field
|
|
29
|
+
|
|
30
|
+
from neon_data_models.models.base import BaseModel
|
|
31
|
+
from neon_data_models.models.base.contexts import (SessionContext, KlatContext,
|
|
32
|
+
TimingContext, MQContext)
|
|
33
|
+
from neon_data_models.models.client import NodeData
|
|
34
|
+
from neon_data_models.models.user import NeonUserConfig
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class MessageContext(BaseModel):
|
|
38
|
+
model_config = ConfigDict(extra="allow")
|
|
39
|
+
session: Optional[SessionContext] = Field(description="Session Data",
|
|
40
|
+
default=None)
|
|
41
|
+
node_data: Optional[NodeData] = Field(description="Node Data", default=None)
|
|
42
|
+
timing: Optional[TimingContext] = Field(
|
|
43
|
+
description="User Interaction Timing Information", default=None)
|
|
44
|
+
user_profiles: Optional[List[NeonUserConfig]] = (
|
|
45
|
+
Field(description="List of relevant user profiles", default=None))
|
|
46
|
+
klat_data: Optional[KlatContext] = Field(
|
|
47
|
+
description="Klat context for Klat-generated messages", default=None)
|
|
48
|
+
mq: Optional[MQContext] = Field(
|
|
49
|
+
description="MQ context for messages traversing a RabbitMQ broker",
|
|
50
|
+
default=None)
|
|
51
|
+
|
|
52
|
+
username: str = "local"
|
|
53
|
+
# TODO: Consider refactoring client/client_name into a single dict
|
|
54
|
+
# or merging with `node_data`
|
|
55
|
+
client_name: str = "unknown"
|
|
56
|
+
client: str = "unknown"
|
|
57
|
+
source: Union[str, List[str]] = "unknown"
|
|
58
|
+
destination: List[str] = ["skills"]
|
|
59
|
+
neon_should_respond: bool = True
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class BaseMessage(BaseModel):
|
|
63
|
+
msg_type: str
|
|
64
|
+
data: dict
|
|
65
|
+
context: MessageContext
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from neon_data_models.models.client.node import *
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from uuid import uuid4
|
|
28
|
+
from pydantic import Field
|
|
29
|
+
from typing import Optional, Dict
|
|
30
|
+
from neon_data_models.models.base import BaseModel
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class NodeSoftware(BaseModel):
|
|
34
|
+
operating_system: str = ""
|
|
35
|
+
os_version: str = ""
|
|
36
|
+
neon_packages: Optional[Dict[str, str]] = None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class NodeNetworking(BaseModel):
|
|
40
|
+
local_ip: str = ""
|
|
41
|
+
public_ip: str = ""
|
|
42
|
+
mac_address: str = ""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class NodeLocation(BaseModel):
|
|
46
|
+
def __init__(self, **kwargs):
|
|
47
|
+
# Enables backwards-compat. with old coordinate values
|
|
48
|
+
if lat := kwargs.pop("lat", None):
|
|
49
|
+
kwargs.setdefault("latitude", lat)
|
|
50
|
+
if lon := kwargs.pop("lon", None):
|
|
51
|
+
kwargs.setdefault("longitude", lon)
|
|
52
|
+
BaseModel.__init__(self, **kwargs)
|
|
53
|
+
latitude: Optional[float] = None
|
|
54
|
+
longitude: Optional[float] = None
|
|
55
|
+
site_id: Optional[str] = None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class NodeData(BaseModel):
|
|
59
|
+
device_id: str = Field(default_factory=lambda: str(uuid4()))
|
|
60
|
+
device_name: str = ""
|
|
61
|
+
device_description: str = ""
|
|
62
|
+
platform: str = ""
|
|
63
|
+
networking: NodeNetworking = NodeNetworking()
|
|
64
|
+
software: NodeSoftware = NodeSoftware()
|
|
65
|
+
location: NodeLocation = NodeLocation()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
__all__ = [NodeSoftware.__name__, NodeNetworking.__name__,
|
|
69
|
+
NodeLocation.__name__, NodeData.__name__]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from neon_data_models.models.user.database import *
|
|
28
|
+
from neon_data_models.models.user.neon_profile import *
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
from time import time
|
|
28
|
+
from typing import Dict, Any, List, Literal, Optional
|
|
29
|
+
from uuid import uuid4
|
|
30
|
+
from neon_data_models.models.base import BaseModel
|
|
31
|
+
from pydantic import Field
|
|
32
|
+
from datetime import date
|
|
33
|
+
|
|
34
|
+
from neon_data_models.enum import AccessRoles
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class _UserConfig(BaseModel):
|
|
38
|
+
first_name: str = ""
|
|
39
|
+
middle_name: str = ""
|
|
40
|
+
last_name: str = ""
|
|
41
|
+
preferred_name: str = ""
|
|
42
|
+
dob: Optional[date] = None
|
|
43
|
+
email: str = ""
|
|
44
|
+
avatar_url: str = Field(default="",
|
|
45
|
+
description="Fully-qualified URI of a user avatar. "
|
|
46
|
+
"(i.e. `https://example.com/avatar.jpg")
|
|
47
|
+
about: str = ""
|
|
48
|
+
phone: str = ""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class _LanguageConfig(BaseModel):
|
|
52
|
+
input_languages: List[str] = ["en-us"]
|
|
53
|
+
output_languages: List[str] = ["en-us"]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class _UnitsConfig(BaseModel):
|
|
57
|
+
time: Literal[12, 24] = 12
|
|
58
|
+
date: Literal["MDY", "YMD", "YDM", "DMY"] = "MDY"
|
|
59
|
+
measure: Literal["imperial", "metric"] = "imperial"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class _ResponseConfig(BaseModel):
|
|
63
|
+
hesitation: bool = False
|
|
64
|
+
limit_dialog: bool = False
|
|
65
|
+
tts_gender: Literal["male", "female"] = "female"
|
|
66
|
+
tts_speed_multiplier: float = 1.0
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class _LocationConfig(BaseModel):
|
|
70
|
+
latitude: Optional[float] = None
|
|
71
|
+
longitude: Optional[float] = None
|
|
72
|
+
name: Optional[str] = None
|
|
73
|
+
timezone: Optional[str] = None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class _PrivacyConfig(BaseModel):
|
|
77
|
+
save_text: bool = True
|
|
78
|
+
save_audio: bool = False
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class NeonUserConfig(BaseModel):
|
|
82
|
+
"""
|
|
83
|
+
Defines user configuration used in Neon Core.
|
|
84
|
+
"""
|
|
85
|
+
skills: Dict[str, Dict[str, Any]] = {}
|
|
86
|
+
user: _UserConfig = _UserConfig()
|
|
87
|
+
# Former `speech` schema is replaced by `language` which is a more general
|
|
88
|
+
# format.
|
|
89
|
+
language: _LanguageConfig = _LanguageConfig()
|
|
90
|
+
units: _UnitsConfig = _UnitsConfig()
|
|
91
|
+
# Former `location` schema is replaced here with a minimal spec from which
|
|
92
|
+
# the remaining values may be calculated
|
|
93
|
+
location: _LocationConfig = _LocationConfig()
|
|
94
|
+
response_mode: _ResponseConfig = _ResponseConfig()
|
|
95
|
+
privacy: _PrivacyConfig = _PrivacyConfig()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class KlatConfig(BaseModel):
|
|
99
|
+
"""
|
|
100
|
+
Defines user configuration used in PyKlatChat.
|
|
101
|
+
"""
|
|
102
|
+
is_tmp: bool = True
|
|
103
|
+
preferences: Dict[str, Any] = {}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class BrainForgeConfig(BaseModel):
|
|
107
|
+
"""
|
|
108
|
+
Defines configuration used in BrainForge LLM applications.
|
|
109
|
+
"""
|
|
110
|
+
inference_access: Dict[str, Dict[str, List[str]]] = {}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class PermissionsConfig(BaseModel):
|
|
114
|
+
"""
|
|
115
|
+
Defines roles for supported projects/service families.
|
|
116
|
+
"""
|
|
117
|
+
klat: AccessRoles = AccessRoles.NONE
|
|
118
|
+
core: AccessRoles = AccessRoles.NONE
|
|
119
|
+
diana: AccessRoles = AccessRoles.NONE
|
|
120
|
+
node: AccessRoles = AccessRoles.NONE
|
|
121
|
+
hub: AccessRoles = AccessRoles.NONE
|
|
122
|
+
llm: AccessRoles = AccessRoles.NONE
|
|
123
|
+
|
|
124
|
+
class Config:
|
|
125
|
+
use_enum_values = True
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class TokenConfig(BaseModel):
|
|
129
|
+
username: str
|
|
130
|
+
client_id: str
|
|
131
|
+
permissions: Dict[str, bool]
|
|
132
|
+
refresh_token: str
|
|
133
|
+
expiration: int = Field(
|
|
134
|
+
description="Unix timestamp of auth token expiration")
|
|
135
|
+
refresh_expiration: int = Field(
|
|
136
|
+
description="Unix timestamp of refresh token expiration")
|
|
137
|
+
token_name: str
|
|
138
|
+
creation_timestamp: int = Field(
|
|
139
|
+
description="Unix timestamp of auth token creation")
|
|
140
|
+
last_refresh_timestamp: int = Field(
|
|
141
|
+
description="Unix timestamp of last auth token refresh")
|
|
142
|
+
access_token: Optional[str] = None
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class User(BaseModel):
|
|
146
|
+
username: str
|
|
147
|
+
password_hash: Optional[str] = None
|
|
148
|
+
user_id: str = Field(default_factory=lambda: str(uuid4()))
|
|
149
|
+
created_timestamp: int = Field(default_factory=lambda: round(time()))
|
|
150
|
+
neon: NeonUserConfig = NeonUserConfig()
|
|
151
|
+
klat: KlatConfig = KlatConfig()
|
|
152
|
+
llm: BrainForgeConfig = BrainForgeConfig()
|
|
153
|
+
permissions: PermissionsConfig = PermissionsConfig()
|
|
154
|
+
tokens: Optional[List[TokenConfig]] = []
|
|
155
|
+
|
|
156
|
+
def __eq__(self, other):
|
|
157
|
+
return self.model_dump() == other.model_dump()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
__all__ = [NeonUserConfig.__name__, KlatConfig.__name__,
|
|
161
|
+
BrainForgeConfig.__name__, PermissionsConfig.__name__,
|
|
162
|
+
TokenConfig.__name__, User.__name__]
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
import pytz
|
|
28
|
+
import datetime
|
|
29
|
+
|
|
30
|
+
from typing import Optional, List, Literal
|
|
31
|
+
|
|
32
|
+
from pydantic import Field
|
|
33
|
+
|
|
34
|
+
from neon_data_models.models.base import BaseModel
|
|
35
|
+
|
|
36
|
+
from neon_data_models.models.user.database import User
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ProfileUser(BaseModel):
|
|
40
|
+
first_name: str = ""
|
|
41
|
+
middle_name: str = ""
|
|
42
|
+
last_name: str = ""
|
|
43
|
+
preferred_name: str = ""
|
|
44
|
+
full_name: str = ""
|
|
45
|
+
dob: str = "YYYY/MM/DD"
|
|
46
|
+
age: str = ""
|
|
47
|
+
email: str = ""
|
|
48
|
+
username: str = ""
|
|
49
|
+
password: str = ""
|
|
50
|
+
picture: str = Field(default="",
|
|
51
|
+
description="Fully-qualified URI of a user avatar. "
|
|
52
|
+
"(i.e. `https://example.com/avatar.jpg")
|
|
53
|
+
about: str = ""
|
|
54
|
+
phone: str = ""
|
|
55
|
+
phone_verified: bool = False
|
|
56
|
+
email_verified: bool = False
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ProfileSpeech(BaseModel):
|
|
60
|
+
stt_language: str = "en-us"
|
|
61
|
+
alt_languages: List[str] = ['en']
|
|
62
|
+
tts_language: str = "en-us"
|
|
63
|
+
tts_gender: str = "female"
|
|
64
|
+
neon_voice: Optional[str] = ''
|
|
65
|
+
secondary_tts_language: Optional[str] = ''
|
|
66
|
+
secondary_tts_gender: str = "male"
|
|
67
|
+
secondary_neon_voice: str = ''
|
|
68
|
+
speed_multiplier: float = 1.0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class ProfileUnits(BaseModel):
|
|
72
|
+
time: Literal[12, 24] = 12
|
|
73
|
+
date: Literal["MDY", "YMD", "YDM", "DMY"] = "MDY"
|
|
74
|
+
measure: Literal["imperial", "metric"] = "imperial"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class ProfileLocation(BaseModel):
|
|
78
|
+
lat: Optional[float] = None
|
|
79
|
+
lng: Optional[float] = None
|
|
80
|
+
city: Optional[str] = None
|
|
81
|
+
state: Optional[str] = None
|
|
82
|
+
country: Optional[str] = None
|
|
83
|
+
tz: Optional[str] = None
|
|
84
|
+
utc: Optional[float] = None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ProfileResponseMode(BaseModel):
|
|
88
|
+
speed_mode: str = "quick"
|
|
89
|
+
hesitation: bool = False
|
|
90
|
+
limit_dialog: bool = False
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class ProfilePrivacy(BaseModel):
|
|
94
|
+
save_audio: bool = False
|
|
95
|
+
save_text: bool = False
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class UserProfile(BaseModel):
|
|
99
|
+
user: ProfileUser = ProfileUser()
|
|
100
|
+
speech: ProfileSpeech = ProfileSpeech()
|
|
101
|
+
units: ProfileUnits = ProfileUnits()
|
|
102
|
+
location: ProfileLocation = ProfileLocation()
|
|
103
|
+
response_mode: ProfileResponseMode = ProfileResponseMode()
|
|
104
|
+
privacy: ProfilePrivacy = ProfilePrivacy()
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def from_user_object(cls, user: User):
|
|
108
|
+
user_config = user.neon
|
|
109
|
+
today = datetime.date.today()
|
|
110
|
+
if user_config.user.dob:
|
|
111
|
+
dob = user_config.user.dob
|
|
112
|
+
age = str(today.year - dob.year - (
|
|
113
|
+
(today.month, today.day) < (dob.month, dob.day)))
|
|
114
|
+
dob = dob.strftime("%Y/%m/%d")
|
|
115
|
+
else:
|
|
116
|
+
age = ""
|
|
117
|
+
dob = "YYYY/MM/DD"
|
|
118
|
+
full_name = " ".join((n for n in (user_config.user.first_name,
|
|
119
|
+
user_config.user.middle_name,
|
|
120
|
+
user_config.user.last_name) if n))
|
|
121
|
+
user = ProfileUser(about=user_config.user.about,
|
|
122
|
+
age=age, dob=dob,
|
|
123
|
+
email=user_config.user.email,
|
|
124
|
+
email_verified=False,
|
|
125
|
+
first_name=user_config.user.first_name,
|
|
126
|
+
full_name=full_name,
|
|
127
|
+
last_name=user_config.user.last_name,
|
|
128
|
+
middle_name=user_config.user.middle_name,
|
|
129
|
+
password=user.password_hash or "",
|
|
130
|
+
phone=user_config.user.phone,
|
|
131
|
+
phone_verified=False,
|
|
132
|
+
picture=user_config.user.avatar_url,
|
|
133
|
+
preferred_name=user_config.user.preferred_name,
|
|
134
|
+
username=user.username
|
|
135
|
+
)
|
|
136
|
+
alt_stt = [lang.split('-')[0] for lang in
|
|
137
|
+
user_config.language.input_languages[1:]]
|
|
138
|
+
secondary_tts_lang = user_config.language.output_languages[1] if (
|
|
139
|
+
len(user_config.language.output_languages) > 1) else None
|
|
140
|
+
speech = ProfileSpeech(
|
|
141
|
+
alt_languages=alt_stt,
|
|
142
|
+
secondary_tts_gender=user_config.response_mode.tts_gender,
|
|
143
|
+
secondary_tts_language=secondary_tts_lang,
|
|
144
|
+
speed_multiplier=user_config.response_mode.tts_speed_multiplier,
|
|
145
|
+
stt_language=user_config.language.input_languages[0].split('-')[0],
|
|
146
|
+
tts_gender=user_config.response_mode.tts_gender,
|
|
147
|
+
tts_language=user_config.language.output_languages[0])
|
|
148
|
+
units = ProfileUnits(**user_config.units.model_dump())
|
|
149
|
+
utc_hours = (pytz.timezone(user_config.location.timezone or "UTC")
|
|
150
|
+
.utcoffset(datetime.datetime.now()).total_seconds() / 3600)
|
|
151
|
+
# TODO: Get city, state, country from lat/lon
|
|
152
|
+
location = ProfileLocation(lat=user_config.location.latitude,
|
|
153
|
+
lng=user_config.location.longitude,
|
|
154
|
+
tz=user_config.location.timezone,
|
|
155
|
+
utc=utc_hours)
|
|
156
|
+
response_mode = ProfileResponseMode(
|
|
157
|
+
**user_config.response_mode.model_dump())
|
|
158
|
+
privacy = ProfilePrivacy(**user_config.privacy.model_dump())
|
|
159
|
+
|
|
160
|
+
return UserProfile(location=location, privacy=privacy,
|
|
161
|
+
response_mode=response_mode, speech=speech,
|
|
162
|
+
units=units, user=user)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
__all__ = [ProfileUser.__name__, ProfileSpeech.__name__, ProfileUnits.__name__,
|
|
166
|
+
ProfileLocation.__name__, ProfileResponseMode.__name__,
|
|
167
|
+
ProfilePrivacy.__name__, UserProfile.__name__]
|
neon_data_models/util.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
13
|
+
# contributors may be used to endorse or promote products derived from this
|
|
14
|
+
# software without specific prior written permission.
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
import json
|
|
28
|
+
|
|
29
|
+
from os import makedirs
|
|
30
|
+
from os.path import join, dirname
|
|
31
|
+
from typing import Optional
|
|
32
|
+
from pydantic import BaseModel
|
|
33
|
+
|
|
34
|
+
import neon_data_models.models
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def build_json_schema(output_path: Optional[str] = None):
|
|
38
|
+
"""
|
|
39
|
+
Builds JSON schema for all Pydantic models in this module.
|
|
40
|
+
"""
|
|
41
|
+
root_path = output_path or join(dirname(__file__), 'schema')
|
|
42
|
+
for obj in neon_data_models.models.__dict__.values():
|
|
43
|
+
try:
|
|
44
|
+
if issubclass(obj, BaseModel) and obj.__name__ != "BaseModel":
|
|
45
|
+
path_parts = obj.__module__.split('.')[2:]
|
|
46
|
+
out_path = join(root_path, *path_parts,
|
|
47
|
+
f"{obj.__name__}.json")
|
|
48
|
+
makedirs(dirname(out_path), exist_ok=True)
|
|
49
|
+
with open(out_path, 'w+') as f:
|
|
50
|
+
json.dump(obj.model_json_schema(), f, indent=2)
|
|
51
|
+
except TypeError:
|
|
52
|
+
pass
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
|
|
5
|
+
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
|
|
6
|
+
# BSD-3 License
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions are met:
|
|
9
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer.
|
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
15
|
+
# contributors may be used to endorse or promote products derived from this
|
|
16
|
+
# software without specific prior written permission.
|
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
19
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
21
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
22
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
23
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
24
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
25
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
26
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
__version__ = "0.0.0a1"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
|
|
2
|
+
# All trademark and other rights reserved by their respective owners
|
|
3
|
+
# Copyright 2008-2024 Neongecko.com Inc.
|
|
4
|
+
# BSD-3
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
|
7
|
+
following conditions are met:
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
|
9
|
+
disclaimer.
|
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
|
|
11
|
+
disclaimer in the documentation and/or other materials provided with the distribution.
|
|
12
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
|
|
13
|
+
derived from this software without specific prior written permission.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
16
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
18
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
19
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
20
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
21
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: neon-data-models
|
|
3
|
+
Version: 0.0.0a1
|
|
4
|
+
Summary: Pydantic models and associated JSON schema definitions
|
|
5
|
+
Home-page: https://github.com/NeonGeckoCom/neon-data-models
|
|
6
|
+
Author: NeonGecko
|
|
7
|
+
Author-email: developers@neon.ai
|
|
8
|
+
License: BSD-3-Clause
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE.md
|
|
13
|
+
Requires-Dist: pydantic~=2.9
|
|
14
|
+
Requires-Dist: pytz
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: pytest; extra == "test"
|
|
17
|
+
|
|
18
|
+
## Neon Data Models
|
|
19
|
+
This repository contains Pydantic models and JSON schemas for common data
|
|
20
|
+
structures. The `models` module contains Pydantic models, organized by application.
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
To allow passing or handling parameters that are not explicitly defined in the
|
|
24
|
+
models provided by this package, the `NEON_DATA_MODELS_ALLOW_EXTRA` envvar may
|
|
25
|
+
be set to `true`. This is generally not necessary and helps to prevent sending
|
|
26
|
+
extraneous data, but may help in cases where the server and client are using
|
|
27
|
+
different revisions of this package.
|
|
28
|
+
|
|
29
|
+
## Organization
|
|
30
|
+
Models are broadly organized into the following categories.
|
|
31
|
+
|
|
32
|
+
### API
|
|
33
|
+
These schemas are used in API requests and responses. They are grouped by the
|
|
34
|
+
applicable API (node, HANA, mq). Use these schemas for sending requests and
|
|
35
|
+
parsing responses.
|
|
36
|
+
|
|
37
|
+
### Client
|
|
38
|
+
These schemas are specific to client applications (i.e. Nodes). Use these
|
|
39
|
+
schemas for client-specific configuration.
|
|
40
|
+
|
|
41
|
+
### User
|
|
42
|
+
These schemas define user-specific data structures. Use these schemas for
|
|
43
|
+
user-specific configuration.
|
|
44
|
+
|
|
45
|
+
### Messagebus
|
|
46
|
+
These schemas define messages sent on the messagebus. Historically, messagebus
|
|
47
|
+
events have not used any validation, so there is greater risk of Message objects
|
|
48
|
+
failing validation than other schemas defined here.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
neon_data_models/__init__.py,sha256=8YnfV3nxHf8pBnppb9HpeYNqMg74ZaTbC4VV39k8BE4,1685
|
|
2
|
+
neon_data_models/enum.py,sha256=D9q5wfgO6mDevkT_oefY_NDlCbVDKEFVmBRhoei3NwU,2744
|
|
3
|
+
neon_data_models/util.py,sha256=bFr99qMIR3at8SIgtR97ywam1WdEV0mMb9xF8qQ0Rc4,2587
|
|
4
|
+
neon_data_models/version.py,sha256=VxMmU2D4uripME5XfS253pLSL1yBv3sRDQS-pfJX4Uo,1856
|
|
5
|
+
neon_data_models/models/__init__.py,sha256=8YnfV3nxHf8pBnppb9HpeYNqMg74ZaTbC4VV39k8BE4,1685
|
|
6
|
+
neon_data_models/models/api/__init__.py,sha256=UBNvoSImNonGoUjibcyVd5sUJRLXxvRUpcIqin6TsIw,1781
|
|
7
|
+
neon_data_models/models/api/mq.py,sha256=_pfGEKmEBDBOlBlgVFtNyCCyYUDkTCypErVbvTeZfvc,2094
|
|
8
|
+
neon_data_models/models/api/node_v1/__init__.py,sha256=VUwr8fJm7usc7oJRZzqlHYFf3dy3NplDUvb5O9m0r6Y,5871
|
|
9
|
+
neon_data_models/models/base/__init__.py,sha256=TmNCAU8blsOFN5BxoDN2aE2M1-Qn87RQ0D0F2tmKX_Y,1936
|
|
10
|
+
neon_data_models/models/base/contexts.py,sha256=k5Da8nid-Ih7GUy28Czy7xxuqrDfa5NwzyuAD5hNo5A,4241
|
|
11
|
+
neon_data_models/models/base/messagebus.py,sha256=NgRSeVre_TPY0vxNxk3k-5cvcz5QMap55xWM4wieJYg,3296
|
|
12
|
+
neon_data_models/models/client/__init__.py,sha256=pPA3-qiv3FeXLWWGZ4LOFG1RzEX9jIjQo2rbJpWxkOQ,1736
|
|
13
|
+
neon_data_models/models/client/node.py,sha256=HzOc-ixale1JamdZG5v4pgyP3HcpYY-_FNE2HH48SEY,2960
|
|
14
|
+
neon_data_models/models/user/__init__.py,sha256=aYTi84ZtmIQltzqqfnerOQcbxQxU3eAbHRucHmVmLXo,1794
|
|
15
|
+
neon_data_models/models/user/database.py,sha256=kL9VhECehNSdBrGnKcs51vtoJvbdjgcFqBxKNvNrdzM,5791
|
|
16
|
+
neon_data_models/models/user/neon_profile.py,sha256=dxDJF7rqtSwtH4BfueAjsqiR1cLC9EJm_OaUj-tXo3w,7116
|
|
17
|
+
neon_data_models-0.0.0a1.dist-info/LICENSE.md,sha256=Qu3UMcoPqNXAk71jELaebP8egnqVId7XImoX1Ejdozs,1626
|
|
18
|
+
neon_data_models-0.0.0a1.dist-info/METADATA,sha256=FtrnX-gxQwlpCAjzDECUMJDDLYYYE0k_oVWrkRTsrok,1804
|
|
19
|
+
neon_data_models-0.0.0a1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
20
|
+
neon_data_models-0.0.0a1.dist-info/top_level.txt,sha256=OY2pqFYhZRbKk-RL_Utz-RJRXyhaX26S5l7N9iWvArk,17
|
|
21
|
+
neon_data_models-0.0.0a1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
22
|
+
neon_data_models-0.0.0a1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
neon_data_models
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|