synapsai-python 0.1.0__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.
@@ -0,0 +1,244 @@
1
+ # Copyright 2026 SynapsAI Technologies Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Chat completion type definitions
17
+ """
18
+
19
+ from typing import Optional, Dict, Any, Union, List, Literal
20
+ from pydantic import BaseModel, Field, ConfigDict
21
+ from enum import Enum
22
+
23
+ from .common import APIResponse, FinishReason, Usage
24
+
25
+
26
+ class ChatRole(str, Enum):
27
+ """Chat message roles"""
28
+ SYSTEM = "system"
29
+ USER = "user"
30
+ ASSISTANT = "assistant"
31
+ FUNCTION = "function"
32
+ TOOL = "tool"
33
+ DEVELOPER = "developer"
34
+
35
+
36
+ class ReasoningEffort(str, Enum):
37
+ """Reasoning effort levels for reasoning models (vLLM only)"""
38
+ NONE = "none"
39
+ MINIMAL = "minimal"
40
+ LOW = "low"
41
+ MEDIUM = "medium"
42
+ HIGH = "high"
43
+ XHIGH = "xhigh"
44
+ MAX = "max"
45
+
46
+
47
+ class FunctionCall(BaseModel):
48
+ """Function call object (legacy; prefer tool_calls)"""
49
+ name: str
50
+ arguments: str
51
+
52
+
53
+ class ChatCompletionMessageToolCallFunction(BaseModel):
54
+ """The function that the model called."""
55
+ name: str
56
+ arguments: str
57
+
58
+
59
+ class ToolCall(BaseModel):
60
+ """A tool call generated by the model (OpenAI-compatible)."""
61
+ id: str
62
+ type: Literal["function"] = "function"
63
+ function: ChatCompletionMessageToolCallFunction
64
+
65
+
66
+ # OpenAI SDK alias
67
+ ChatCompletionMessageToolCall = ToolCall
68
+
69
+
70
+ class DeltaFunctionCall(BaseModel):
71
+ """Partial function call fields in a streaming delta."""
72
+ name: Optional[str] = None
73
+ arguments: Optional[str] = None
74
+
75
+
76
+ class DeltaToolCall(BaseModel):
77
+ """A tool call delta in a streaming response (OpenAI-compatible)."""
78
+ index: int
79
+ id: Optional[str] = None
80
+ type: Optional[Literal["function"]] = None
81
+ function: Optional[DeltaFunctionCall] = None
82
+
83
+
84
+ # OpenAI SDK alias
85
+ ChoiceDeltaToolCall = DeltaToolCall
86
+
87
+
88
+ class ChatCompletionNamedToolChoice(BaseModel):
89
+ """Force the model to call a specific function."""
90
+ type: Literal["function"] = "function"
91
+ function: Dict[str, str]
92
+
93
+
94
+ ToolChoice = Union[
95
+ Literal["none", "auto", "required"],
96
+ ChatCompletionNamedToolChoice,
97
+ Dict[str, Any],
98
+ ]
99
+
100
+
101
+ class ChatMessage(BaseModel):
102
+ """Chat message object"""
103
+ model_config = ConfigDict(extra="ignore")
104
+
105
+ role: Union[ChatRole, str]
106
+ content: Optional[str] = None
107
+ name: Optional[str] = None
108
+ refusal: Optional[str] = None
109
+ reasoning: Optional[str] = None
110
+ function_call: Optional[FunctionCall] = None
111
+ tool_calls: Optional[List[ToolCall]] = None
112
+ tool_call_id: Optional[str] = None
113
+
114
+
115
+ class Function(BaseModel):
116
+ """Function definition"""
117
+ name: str
118
+ description: Optional[str] = None
119
+ parameters: Optional[Dict[str, Any]] = None
120
+
121
+
122
+ class Tool(BaseModel):
123
+ """Tool definition"""
124
+ type: Literal["function"] = "function"
125
+ function: Function
126
+
127
+
128
+ class ResponseFormat(BaseModel):
129
+ """Response format specification"""
130
+ type: Literal["text", "json_object"] = "text"
131
+
132
+
133
+ class ChatCompletionRequest(BaseModel):
134
+ """Chat completion request"""
135
+ model: str
136
+ messages: List[ChatMessage]
137
+ temperature: Optional[float] = Field(default=1.0, ge=0.0, le=2.0)
138
+ top_p: Optional[float] = Field(default=1.0, ge=0.0, le=1.0)
139
+ n: Optional[int] = Field(default=1, ge=1)
140
+ stream: Optional[bool] = False
141
+ stop: Optional[Union[str, List[str]]] = None
142
+ max_tokens: Optional[int] = Field(default=None, gt=0)
143
+ presence_penalty: Optional[float] = Field(default=0.0, ge=-2.0, le=2.0)
144
+ frequency_penalty: Optional[float] = Field(default=0.0, ge=-2.0, le=2.0)
145
+ logit_bias: Optional[Dict[str, float]] = None
146
+ functions: Optional[List[Function]] = None
147
+ function_call: Optional[Union[str, Dict[str, str]]] = None
148
+ tools: Optional[List[Tool]] = None
149
+ tool_choice: Optional[ToolChoice] = None
150
+ response_format: Optional[ResponseFormat] = None
151
+ seed: Optional[int] = None
152
+ reasoning_effort: Optional[ReasoningEffort] = None
153
+
154
+
155
+ class CompletionRequest(BaseModel):
156
+ """Completion request"""
157
+ model: str
158
+ prompt: str
159
+ temperature: Optional[float] = Field(default=1.0, ge=0.0, le=2.0)
160
+ top_p: Optional[float] = Field(default=1.0, ge=0.0, le=1.0)
161
+ n: Optional[int] = Field(default=1, ge=1)
162
+ stream: Optional[bool] = False
163
+ stop: Optional[Union[str, List[str]]] = None
164
+ max_tokens: Optional[int] = Field(default=None, gt=0)
165
+ presence_penalty: Optional[float] = Field(default=0.0, ge=-2.0, le=2.0)
166
+ frequency_penalty: Optional[float] = Field(default=0.0, ge=-2.0, le=2.0)
167
+ logit_bias: Optional[Dict[str, float]] = None
168
+ response_format: Optional[ResponseFormat] = None
169
+ seed: Optional[int] = None
170
+
171
+
172
+ class Delta(BaseModel):
173
+ """Delta object for streaming responses"""
174
+ model_config = ConfigDict(extra="ignore")
175
+
176
+ role: Optional[Union[ChatRole, str]] = None
177
+ content: Optional[str] = None
178
+ refusal: Optional[str] = None
179
+ reasoning: Optional[str] = None
180
+ function_call: Optional[DeltaFunctionCall] = None
181
+ tool_calls: Optional[List[DeltaToolCall]] = None
182
+
183
+
184
+ # OpenAI SDK alias
185
+ ChoiceDelta = Delta
186
+
187
+
188
+ class ChatCompletionChoice(BaseModel):
189
+ """Choice object"""
190
+ model_config = ConfigDict(extra="ignore")
191
+
192
+ index: int = Field(default=0)
193
+ message: Optional[ChatMessage] = None
194
+ delta: Optional[Delta] = None
195
+ logprobs: Optional[dict | list[dict]] = None
196
+ finish_reason: Optional[Union[FinishReason, str]] = None
197
+
198
+
199
+ class CompletionChoice(BaseModel):
200
+ """Choice object"""
201
+ index: int = Field(default=0)
202
+ text: str
203
+ logprobs: Optional[dict | list[dict]] = None
204
+ finish_reason: Optional[Union[FinishReason, str]] = None
205
+
206
+
207
+ class ChatCompletionResponse(APIResponse):
208
+ """Chat completion response"""
209
+ model_config = ConfigDict(extra="ignore")
210
+
211
+ model: str
212
+ object: str
213
+ choices: List[ChatCompletionChoice]
214
+ system_fingerprint: Optional[str] = None
215
+ usage: Optional[Usage] = None
216
+
217
+
218
+ class CompletionResponse(APIResponse):
219
+ """Completion response"""
220
+ model: str
221
+ object: str
222
+ choices: List[CompletionChoice]
223
+ system_fingerprint: Optional[str] = None
224
+ usage: Optional[Usage] = None
225
+
226
+
227
+ class ChatCompletionChunk(APIResponse):
228
+ """Chat completion chunk for streaming"""
229
+ model_config = ConfigDict(extra="ignore")
230
+
231
+ model: str
232
+ object: str
233
+ choices: List[ChatCompletionChoice]
234
+ system_fingerprint: Optional[str] = None
235
+ usage: Optional[Usage] = None
236
+
237
+
238
+ class CompletionChunk(APIResponse):
239
+ """Completion chunk for streaming"""
240
+ model: str
241
+ object: str
242
+ choices: List[CompletionChoice]
243
+ system_fingerprint: Optional[str] = None
244
+ usage: Optional[Usage] = None
@@ -0,0 +1,68 @@
1
+ # Copyright 2026 SynapsAI Technologies Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Embeddings type definitions
17
+ """
18
+
19
+ from typing import Optional, List, Literal, Union
20
+ from pydantic import BaseModel, Field
21
+
22
+ from .common import APIResponse, Usage
23
+
24
+
25
+ class Embedding(BaseModel):
26
+ """Embedding object"""
27
+ object: Literal["embedding"] = "embedding"
28
+ embedding: Union[List[float], str]
29
+ index: int = Field(default=0)
30
+
31
+
32
+ class EmbeddingRequest(BaseModel):
33
+ """Embedding request"""
34
+ model: str
35
+ input: Union[str, List[str], List[int], List[List[int]]]
36
+ encoding_format: Optional[Literal["float", "base64"]] = "float"
37
+ dimensions: Optional[int] = Field(default=None, gt=0)
38
+
39
+
40
+ class EmbeddingResponse(APIResponse):
41
+ """Embedding response"""
42
+ object: Literal["list"] = "list"
43
+ data: List[Embedding]
44
+ model: str
45
+ usage: Optional[Usage] = None
46
+
47
+
48
+ class SimilarityRequest(BaseModel):
49
+ """Similarity request for sentence/embedding similarity"""
50
+ model: str
51
+ source_sentence: str
52
+ sentences: List[str]
53
+ return_embeddings: Optional[bool] = False
54
+ encoding_format: Optional[Literal["float", "base64"]] = "float"
55
+
56
+ class SimilarityResult(BaseModel):
57
+ """Single similarity result for a sentence"""
58
+ object: Literal["similarity"] = "similarity"
59
+ similarity: float
60
+ embedding: Optional[Union[List[float], str]] = Field(default=None)
61
+ index: int = Field(default=0)
62
+
63
+ class SimilarityResponse(APIResponse):
64
+ """Similarity response object"""
65
+ object: Literal["list"] = "list"
66
+ data: List[SimilarityResult]
67
+ model: str
68
+ usage: Optional[Usage] = None
@@ -0,0 +1,31 @@
1
+ # Copyright 2026 SynapsAI Technologies Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Feature extraction type definitions
17
+ """
18
+
19
+ from typing import Optional, Dict, Any, Union, List, Literal
20
+ from pydantic import BaseModel
21
+ from .common import APIResponse, Usage
22
+
23
+ class FeatureExtractionRequest(BaseModel):
24
+ model: str
25
+ inputs: Union[str, List[str]]
26
+
27
+ class FeatureExtractionResponse(APIResponse):
28
+ object: Literal["list"] = "list"
29
+ data: List[Dict[str, Any]]
30
+ model: str
31
+ usage: Optional[Usage] = None
@@ -0,0 +1,38 @@
1
+ # Copyright 2026 SynapsAI Technologies Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Fill mask type definitions
17
+ """
18
+
19
+ from typing import Optional, Union, List, Literal
20
+ from pydantic import BaseModel
21
+ from .common import APIResponse, Usage
22
+
23
+ class FillMaskRequest(BaseModel):
24
+ model: str
25
+ inputs: Union[str, List[str]]
26
+ targets: Optional[Union[str, List[str]]] = None
27
+ top_k: int = 5
28
+
29
+ class FillMaskData(BaseModel):
30
+ """Data model for fill mask result"""
31
+ masks: List[str]
32
+ score: float
33
+
34
+ class FillMaskResponse(APIResponse):
35
+ object: Literal["list"] = "list"
36
+ data: List[FillMaskData]
37
+ model: str
38
+ usage: Optional[Usage] = None
@@ -0,0 +1,172 @@
1
+ # Copyright 2026 SynapsAI Technologies Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Image generation, editing, and analysis type definitions
17
+ """
18
+
19
+ from typing import Optional, Dict, Any, Union, List, Literal, Tuple
20
+ from pydantic import BaseModel, Field
21
+ from enum import Enum
22
+
23
+ from .common import APIResponse, Usage
24
+
25
+ ImageSource = Union[str, bytes, List[str], List[bytes]]
26
+
27
+ class ResponseFormat(str, Enum):
28
+ """Image response format"""
29
+ URL = "url"
30
+ B64_JSON = "b64_json"
31
+
32
+ class Image(BaseModel):
33
+ """Image object"""
34
+ url: Optional[str] = None
35
+ b64_json: Optional[str] = None
36
+ image_bytes: Optional[bytes] = None
37
+ revised_prompt: Optional[str] = None
38
+
39
+ class ImageGenerateRequest(BaseModel):
40
+ """Image generation request"""
41
+ model: str
42
+ prompt: str = Field(max_length=4000)
43
+ n: Optional[int] = Field(default=1, ge=1, le=10)
44
+ response_format: ResponseFormat = ResponseFormat.URL
45
+ size: Union[Tuple[int, int], str] = "512x512"
46
+
47
+ class ImageGenerateResponse(APIResponse):
48
+ """Image generation response"""
49
+ object: Literal["list"] = "list"
50
+ data: List[Image]
51
+ usage: Optional[Usage] = None
52
+
53
+ class ImageEditRequest(BaseModel):
54
+ """Image edit request"""
55
+ model: str
56
+ image: ImageSource = Field(description="The image to edit (base64 encoded, URL, or file)")
57
+ mask: Optional[ImageSource] = Field(default=None, description="Mask image (base64 encoded, URL, or file)")
58
+ prompt: str = Field(max_length=1000)
59
+ n: Optional[int] = Field(default=1, ge=1, le=10)
60
+ size: Union[Tuple[int, int], str] = "512x512"
61
+ response_format: ResponseFormat = ResponseFormat.URL
62
+
63
+ class ImageEditResponse(APIResponse):
64
+ """Image edit response"""
65
+ object: Literal["list"] = "list"
66
+ data: List[Image]
67
+ usage: Optional[Usage] = None
68
+
69
+ class ImageAnalysisRequest(BaseModel):
70
+ """Image analysis request"""
71
+ model: str
72
+ image: ImageSource = Field(description="The image to analyze (base64 encoded, URL, or file)")
73
+ prompt: Optional[str] = None
74
+ fields: Optional[List[str]] = Field(
75
+ default=None,
76
+ description="Specific fields to extract (e.g., ['objects', 'text', 'colors', 'mood'])"
77
+ )
78
+ detail: Optional[Literal["low", "high", "auto"]] = "auto"
79
+ max_tokens: Optional[int] = Field(default=300, gt=0)
80
+
81
+ class ImageAnalysisResponse(APIResponse):
82
+ """Image analysis response"""
83
+ object: Literal["list"] = "list"
84
+ model: str
85
+ data: List[Dict[str, Any]]
86
+ usage: Optional[Usage] = None
87
+
88
+ class ImageSegmentationRequest(BaseModel):
89
+ """Image segmentation request"""
90
+ model: str
91
+ image: ImageSource = Field(description="The image to analyze (base64 encoded, URL, or file)")
92
+ subtask: str = 'panoptic'
93
+ threshold: float = 0.9
94
+ mask_threshold: float = 0.5
95
+ overlap_mask_area_threshold: float = 0.5
96
+
97
+ class ImageSegmentationResponse(APIResponse):
98
+ """Image segmentation response"""
99
+ object: Literal["list"] = "list"
100
+ model: str
101
+ data: List[Dict[str, Any]]
102
+ usage: Optional[Usage] = None
103
+
104
+ class ImageFeatureExtractionRequest(BaseModel):
105
+ """Image feature extraction request"""
106
+ model: str
107
+ images: ImageSource = Field(description="The image to extract features from (base64 encoded, URL, or file)")
108
+
109
+ class ImageFeatureExtractionResponse(APIResponse):
110
+ """Image feature extraction response"""
111
+ object: Literal["list"] = "list"
112
+ model: str
113
+ data: List[Dict[str, Any]]
114
+ usage: Optional[Usage] = None
115
+
116
+ class ObjectDetectionRequest(BaseModel):
117
+ """Object detection request"""
118
+ model: str
119
+ inputs: ImageSource = Field(description="The image to analyze (base64 encoded, URL, or file)")
120
+ threshold: float = 0.5
121
+
122
+ class ObjectDetectionResponse(APIResponse):
123
+ """Object detection response"""
124
+ object: Literal["list"] = "list"
125
+ model: str
126
+ data: List[Dict[str, Any]]
127
+ usage: Optional[Usage] = None
128
+
129
+ class DepthEstimationRequest(BaseModel):
130
+ """Depth estimation request"""
131
+ model: str
132
+ inputs: ImageSource = Field(description="The image to analyze (base64 encoded, URL, or file)")
133
+ parameters: Optional[Dict] = None
134
+
135
+ class DepthEstimationResponse(APIResponse):
136
+ """Depth estimation response"""
137
+ object: Literal["list"] = "list"
138
+ model: str
139
+ data: List[Dict[str, Any]]
140
+ usage: Optional[Usage] = None
141
+
142
+ class ImageFeatureExtractionRequest(BaseModel):
143
+ """Feature extraction request"""
144
+ model: str
145
+ inputs: ImageSource = Field(description="The image to extract features from (base64 encoded, URL, or file)")
146
+
147
+ class ImageFeatureExtractionResponse(APIResponse):
148
+ """Feature extraction response"""
149
+ object: Literal["list"] = "list"
150
+ model: str
151
+ data: List[Dict[str, Any]]
152
+ usage: Optional[Usage] = None
153
+
154
+ class MaskGenerationRequest(BaseModel):
155
+ """Mask Generation Request"""
156
+ model: str
157
+ image: ImageSource
158
+ mask_threshold: float = 0.0
159
+ pred_iou_thresh: float = 0.88
160
+ stability_score_thresh: float = 0.95
161
+ stability_score_offset: int = 1
162
+ crops_nms_thresh: float = 0.7
163
+ crops_n_layers: int = 0
164
+ crop_overlap_ratio: float = 0.3413
165
+ crop_n_points_downscale_factor: int = 1
166
+
167
+ class MaskGenerationResponse(APIResponse):
168
+ """Mask Generation Response"""
169
+ object: Literal["list"] = "list"
170
+ model: str
171
+ data: List[Dict[str, Any]]
172
+ usage: Optional[Usage] = None
@@ -0,0 +1,28 @@
1
+ # Copyright 2026 SynapsAI Technologies Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from typing import Literal, List
16
+ from pydantic import BaseModel
17
+
18
+ class Model(BaseModel):
19
+ id: str
20
+ object: Literal["model"] = "model"
21
+ created: int
22
+ owned_by: str
23
+ status: Literal["building", "sleeping", "ready", "failed"]
24
+
25
+
26
+ class Models(BaseModel):
27
+ object: Literal["list"] = "list"
28
+ data: List[Model]