mixpeek 0.11.0__tar.gz → 0.11.2__tar.gz
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.
- mixpeek-0.11.2/MANIFEST.in +1 -0
- mixpeek-0.11.2/PKG-INFO +375 -0
- mixpeek-0.11.2/README.md +357 -0
- mixpeek-0.11.2/mixpeek/__init__.py +1 -0
- mixpeek-0.11.2/mixpeek/client.py +27 -0
- mixpeek-0.11.2/mixpeek/endpoints/collections.py +86 -0
- mixpeek-0.11.2/mixpeek/endpoints/embed.py +66 -0
- mixpeek-0.11.2/mixpeek/endpoints/index.py +51 -0
- mixpeek-0.11.2/mixpeek/endpoints/register.py +34 -0
- mixpeek-0.11.2/mixpeek/endpoints/search.py +44 -0
- mixpeek-0.11.2/mixpeek/endpoints/tasks.py +26 -0
- mixpeek-0.11.2/mixpeek/endpoints/tools.py +138 -0
- mixpeek-0.11.2/mixpeek/exceptions.py +13 -0
- mixpeek-0.11.2/mixpeek.egg-info/PKG-INFO +375 -0
- mixpeek-0.11.2/mixpeek.egg-info/SOURCES.txt +20 -0
- mixpeek-0.11.2/mixpeek.egg-info/dependency_links.txt +1 -0
- mixpeek-0.11.2/mixpeek.egg-info/requires.txt +5 -0
- mixpeek-0.11.2/mixpeek.egg-info/top_level.txt +1 -0
- mixpeek-0.11.2/requirements.txt +5 -0
- mixpeek-0.11.2/setup.cfg +4 -0
- mixpeek-0.11.2/setup.py +24 -0
- mixpeek-0.11.0/.gitignore +0 -16
- mixpeek-0.11.0/.release-please-manifest.json +0 -3
- mixpeek-0.11.0/CHANGELOG.md +0 -35
- mixpeek-0.11.0/CONTRIBUTING.md +0 -129
- mixpeek-0.11.0/LICENSE +0 -201
- mixpeek-0.11.0/PKG-INFO +0 -356
- mixpeek-0.11.0/README.md +0 -322
- mixpeek-0.11.0/SECURITY.md +0 -27
- mixpeek-0.11.0/api.md +0 -175
- mixpeek-0.11.0/bin/check-release-environment +0 -21
- mixpeek-0.11.0/bin/publish-pypi +0 -9
- mixpeek-0.11.0/examples/.keep +0 -4
- mixpeek-0.11.0/examples/example.py +0 -9
- mixpeek-0.11.0/mypy.ini +0 -47
- mixpeek-0.11.0/noxfile.py +0 -9
- mixpeek-0.11.0/pyproject.toml +0 -212
- mixpeek-0.11.0/release-please-config.json +0 -66
- mixpeek-0.11.0/requirements-dev.lock +0 -105
- mixpeek-0.11.0/requirements.lock +0 -45
- mixpeek-0.11.0/src/mixpeek/__init__.py +0 -93
- mixpeek-0.11.0/src/mixpeek/_base_client.py +0 -2041
- mixpeek-0.11.0/src/mixpeek/_client.py +0 -444
- mixpeek-0.11.0/src/mixpeek/_compat.py +0 -219
- mixpeek-0.11.0/src/mixpeek/_constants.py +0 -14
- mixpeek-0.11.0/src/mixpeek/_exceptions.py +0 -108
- mixpeek-0.11.0/src/mixpeek/_files.py +0 -123
- mixpeek-0.11.0/src/mixpeek/_models.py +0 -785
- mixpeek-0.11.0/src/mixpeek/_qs.py +0 -150
- mixpeek-0.11.0/src/mixpeek/_resource.py +0 -43
- mixpeek-0.11.0/src/mixpeek/_response.py +0 -824
- mixpeek-0.11.0/src/mixpeek/_streaming.py +0 -333
- mixpeek-0.11.0/src/mixpeek/_types.py +0 -217
- mixpeek-0.11.0/src/mixpeek/_utils/__init__.py +0 -55
- mixpeek-0.11.0/src/mixpeek/_utils/_logs.py +0 -25
- mixpeek-0.11.0/src/mixpeek/_utils/_proxy.py +0 -62
- mixpeek-0.11.0/src/mixpeek/_utils/_reflection.py +0 -42
- mixpeek-0.11.0/src/mixpeek/_utils/_streams.py +0 -12
- mixpeek-0.11.0/src/mixpeek/_utils/_sync.py +0 -81
- mixpeek-0.11.0/src/mixpeek/_utils/_transform.py +0 -382
- mixpeek-0.11.0/src/mixpeek/_utils/_typing.py +0 -120
- mixpeek-0.11.0/src/mixpeek/_utils/_utils.py +0 -397
- mixpeek-0.11.0/src/mixpeek/_version.py +0 -4
- mixpeek-0.11.0/src/mixpeek/lib/.keep +0 -4
- mixpeek-0.11.0/src/mixpeek/resources/__init__.py +0 -159
- mixpeek-0.11.0/src/mixpeek/resources/accounts/__init__.py +0 -33
- mixpeek-0.11.0/src/mixpeek/resources/accounts/accounts.py +0 -102
- mixpeek-0.11.0/src/mixpeek/resources/accounts/private.py +0 -232
- mixpeek-0.11.0/src/mixpeek/resources/agent/__init__.py +0 -33
- mixpeek-0.11.0/src/mixpeek/resources/agent/agent.py +0 -225
- mixpeek-0.11.0/src/mixpeek/resources/agent/task.py +0 -189
- mixpeek-0.11.0/src/mixpeek/resources/collections/__init__.py +0 -33
- mixpeek-0.11.0/src/mixpeek/resources/collections/collections.py +0 -459
- mixpeek-0.11.0/src/mixpeek/resources/collections/files.py +0 -679
- mixpeek-0.11.0/src/mixpeek/resources/describe.py +0 -338
- mixpeek-0.11.0/src/mixpeek/resources/embed.py +0 -234
- mixpeek-0.11.0/src/mixpeek/resources/indexes.py +0 -506
- mixpeek-0.11.0/src/mixpeek/resources/read.py +0 -183
- mixpeek-0.11.0/src/mixpeek/resources/recognize.py +0 -183
- mixpeek-0.11.0/src/mixpeek/resources/search.py +0 -542
- mixpeek-0.11.0/src/mixpeek/resources/tasks.py +0 -297
- mixpeek-0.11.0/src/mixpeek/resources/transcribe.py +0 -192
- mixpeek-0.11.0/src/mixpeek/types/__init__.py +0 -19
- mixpeek-0.11.0/src/mixpeek/types/accounts/__init__.py +0 -6
- mixpeek-0.11.0/src/mixpeek/types/accounts/private_update_params.py +0 -25
- mixpeek-0.11.0/src/mixpeek/types/accounts/user.py +0 -32
- mixpeek-0.11.0/src/mixpeek/types/agent/__init__.py +0 -3
- mixpeek-0.11.0/src/mixpeek/types/agent_create_params.py +0 -18
- mixpeek-0.11.0/src/mixpeek/types/agentresponse.py +0 -11
- mixpeek-0.11.0/src/mixpeek/types/collection_search_params.py +0 -29
- mixpeek-0.11.0/src/mixpeek/types/collections/__init__.py +0 -9
- mixpeek-0.11.0/src/mixpeek/types/collections/file_create_params.py +0 -31
- mixpeek-0.11.0/src/mixpeek/types/collections/file_full_params.py +0 -22
- mixpeek-0.11.0/src/mixpeek/types/collections/file_update_params.py +0 -18
- mixpeek-0.11.0/src/mixpeek/types/collections/fileresponse.py +0 -23
- mixpeek-0.11.0/src/mixpeek/types/collections/groupedfiledata.py +0 -38
- mixpeek-0.11.0/src/mixpeek/types/describe_upload_params.py +0 -21
- mixpeek-0.11.0/src/mixpeek/types/describe_url_params.py +0 -20
- mixpeek-0.11.0/src/mixpeek/types/embed_create_params.py +0 -29
- mixpeek-0.11.0/src/mixpeek/types/embeddingresponse.py +0 -15
- mixpeek-0.11.0/src/mixpeek/types/index_face_params.py +0 -23
- mixpeek-0.11.0/src/mixpeek/types/index_upload_params.py +0 -27
- mixpeek-0.11.0/src/mixpeek/types/index_url_params.py +0 -159
- mixpeek-0.11.0/src/mixpeek/types/search_text_params.py +0 -45
- mixpeek-0.11.0/src/mixpeek/types/search_upload_params.py +0 -25
- mixpeek-0.11.0/src/mixpeek/types/search_url_params.py +0 -45
- mixpeek-0.11.0/src/mixpeek/types/taskresponse.py +0 -15
- mixpeek-0.11.0/src/mixpeek/types/transcribe_url_params.py +0 -18
- mixpeek-0.11.0/src/mixpeek_sdk/lib/.keep +0 -4
- mixpeek-0.11.0/tests/__init__.py +0 -1
- mixpeek-0.11.0/tests/api_resources/__init__.py +0 -1
- mixpeek-0.11.0/tests/api_resources/accounts/__init__.py +0 -1
- mixpeek-0.11.0/tests/api_resources/accounts/test_private.py +0 -171
- mixpeek-0.11.0/tests/api_resources/agent/__init__.py +0 -1
- mixpeek-0.11.0/tests/api_resources/agent/test_task.py +0 -115
- mixpeek-0.11.0/tests/api_resources/collections/__init__.py +0 -1
- mixpeek-0.11.0/tests/api_resources/collections/test_files.py +0 -509
- mixpeek-0.11.0/tests/api_resources/test_agent.py +0 -102
- mixpeek-0.11.0/tests/api_resources/test_collections.py +0 -277
- mixpeek-0.11.0/tests/api_resources/test_describe.py +0 -197
- mixpeek-0.11.0/tests/api_resources/test_embed.py +0 -108
- mixpeek-0.11.0/tests/api_resources/test_indexes.py +0 -381
- mixpeek-0.11.0/tests/api_resources/test_read.py +0 -87
- mixpeek-0.11.0/tests/api_resources/test_recognize.py +0 -87
- mixpeek-0.11.0/tests/api_resources/test_search.py +0 -307
- mixpeek-0.11.0/tests/api_resources/test_tasks.py +0 -210
- mixpeek-0.11.0/tests/api_resources/test_transcribe.py +0 -101
- mixpeek-0.11.0/tests/conftest.py +0 -47
- mixpeek-0.11.0/tests/sample_file.txt +0 -1
- mixpeek-0.11.0/tests/test_client.py +0 -1496
- mixpeek-0.11.0/tests/test_deepcopy.py +0 -58
- mixpeek-0.11.0/tests/test_extract_files.py +0 -64
- mixpeek-0.11.0/tests/test_files.py +0 -51
- mixpeek-0.11.0/tests/test_models.py +0 -829
- mixpeek-0.11.0/tests/test_qs.py +0 -78
- mixpeek-0.11.0/tests/test_required_args.py +0 -111
- mixpeek-0.11.0/tests/test_response.py +0 -277
- mixpeek-0.11.0/tests/test_streaming.py +0 -250
- mixpeek-0.11.0/tests/test_transform.py +0 -410
- mixpeek-0.11.0/tests/test_utils/test_proxy.py +0 -23
- mixpeek-0.11.0/tests/test_utils/test_typing.py +0 -73
- mixpeek-0.11.0/tests/utils.py +0 -155
- /mixpeek-0.11.0/src/mixpeek/py.typed → /mixpeek-0.11.2/mixpeek/endpoints/__init__.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
include requirements.txt
|
mixpeek-0.11.2/PKG-INFO
ADDED
@@ -0,0 +1,375 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: mixpeek
|
3
|
+
Version: 0.11.2
|
4
|
+
Summary: Mixpeek Python SDK
|
5
|
+
Home-page: https://github.com/mixpeek/mixpeek-python
|
6
|
+
Author: Ethan Steininger
|
7
|
+
Author-email: ethan@mixpeek.com
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.6
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
Requires-Dist: requests==2.32.3
|
14
|
+
Requires-Dist: pydantic==2.7.3
|
15
|
+
Requires-Dist: tqdm==4.66.4
|
16
|
+
Requires-Dist: urllib3==2.2.1
|
17
|
+
Requires-Dist: pillow==10.4.0
|
18
|
+
|
19
|
+
# Mixpeek Python SDK
|
20
|
+
|
21
|
+
This SDK provides easy access to the Mixpeek API for Python developers.
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
```bash
|
26
|
+
pip install mixpeek
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
First, import and initialize the Mixpeek client:
|
32
|
+
|
33
|
+
```python
|
34
|
+
from mixpeek import Mixpeek
|
35
|
+
|
36
|
+
client = Mixpeek(api_key="your_api_key_here")
|
37
|
+
```
|
38
|
+
|
39
|
+
### Embed
|
40
|
+
|
41
|
+
The `embed` module provides methods for embedding various types of data.
|
42
|
+
|
43
|
+
#### Video Embedding
|
44
|
+
|
45
|
+
```python
|
46
|
+
response = client.embed.video(model_id="model_id", input="video_data", input_type="base64")
|
47
|
+
```
|
48
|
+
|
49
|
+
- `model_id` (str): The ID of the model to use for embedding.
|
50
|
+
- `input` (str): The video data or URL.
|
51
|
+
- `input_type` (str): Either "base64" or "url".
|
52
|
+
|
53
|
+
#### Text Embedding
|
54
|
+
|
55
|
+
```python
|
56
|
+
response = client.embed.text(model_id="model_id", input="text_to_embed", input_type="text")
|
57
|
+
```
|
58
|
+
|
59
|
+
- `model_id` (str): The ID of the model to use for embedding.
|
60
|
+
- `input` (str): The text to embed.
|
61
|
+
- `input_type` (str): Should be "text".
|
62
|
+
|
63
|
+
#### Image Embedding
|
64
|
+
|
65
|
+
```python
|
66
|
+
response = client.embed.image(model_id="model_id", input="image_data", input_type="base64")
|
67
|
+
```
|
68
|
+
|
69
|
+
- `model_id` (str): The ID of the model to use for embedding.
|
70
|
+
- `input` (str): The image data or URL.
|
71
|
+
- `input_type` (str): Either "base64" or "url".
|
72
|
+
|
73
|
+
#### Audio Embedding
|
74
|
+
|
75
|
+
```python
|
76
|
+
response = client.embed.audio(model_id="model_id", input="audio_data", input_type="base64")
|
77
|
+
```
|
78
|
+
|
79
|
+
- `model_id` (str): The ID of the model to use for embedding.
|
80
|
+
- `input` (str): The audio data or URL.
|
81
|
+
- `input_type` (str): Either "base64" or "url".
|
82
|
+
|
83
|
+
### Index
|
84
|
+
|
85
|
+
The `index` module provides methods for indexing various types of content.
|
86
|
+
|
87
|
+
#### Upload File
|
88
|
+
|
89
|
+
```python
|
90
|
+
with open("file.txt", "rb") as file:
|
91
|
+
response = client.index.upload(file=file, collection_id="collection_id", metadata={"key": "value"}, settings={"video": {"transcribe": True}})
|
92
|
+
```
|
93
|
+
|
94
|
+
- `file` (file object): The file to upload.
|
95
|
+
- `collection_id` (str): The ID of the collection to add the file to.
|
96
|
+
- `metadata` (dict, optional): Additional metadata for the file.
|
97
|
+
- `settings` (dict, optional): Processing settings for the file.
|
98
|
+
|
99
|
+
#### Index URL
|
100
|
+
|
101
|
+
```python
|
102
|
+
response = client.index.url(url="https://example.com", collection_id="collection_id", metadata={"key": "value"}, settings={"image": {"caption_model_id": "model_id"}})
|
103
|
+
```
|
104
|
+
|
105
|
+
- `url` (str): The URL to index.
|
106
|
+
- `collection_id` (str): The ID of the collection to add the content to.
|
107
|
+
- `metadata` (dict, optional): Additional metadata for the content.
|
108
|
+
- `settings` (dict, optional): Processing settings for the content.
|
109
|
+
|
110
|
+
#### Index YouTube Video
|
111
|
+
|
112
|
+
```python
|
113
|
+
response = client.index.youtube(youtube_video_id="video_id", collection_id="collection_id", metadata={"key": "value"}, settings={"video": {"transcribe": True}})
|
114
|
+
```
|
115
|
+
|
116
|
+
- `youtube_video_id` (str): The ID of the YouTube video to index.
|
117
|
+
- `collection_id` (str): The ID of the collection to add the video to.
|
118
|
+
- `metadata` (dict, optional): Additional metadata for the video.
|
119
|
+
- `settings` (dict, optional): Processing settings for the video.
|
120
|
+
|
121
|
+
#### Search YouTube
|
122
|
+
|
123
|
+
```python
|
124
|
+
response = client.index.youtube_search(query="search query", collection_id="collection_id", max_results=20, metadata={"key": "value"}, shorts_only=False)
|
125
|
+
```
|
126
|
+
|
127
|
+
- `query` (str): The search query for YouTube videos.
|
128
|
+
- `collection_id` (str): The ID of the collection to add the search results to.
|
129
|
+
- `max_results` (int, optional): Maximum number of results to return (default: 10, max: 500).
|
130
|
+
- `metadata` (dict, optional): Additional metadata for the search results.
|
131
|
+
- `shorts_only` (bool, optional): Whether to search for YouTube Shorts only (default: False).
|
132
|
+
|
133
|
+
### Search
|
134
|
+
|
135
|
+
The `search` module provides methods for searching indexed content.
|
136
|
+
|
137
|
+
#### Text Search
|
138
|
+
|
139
|
+
```python
|
140
|
+
response = client.search.text(input="search query", modality="text", input_type="text", filters={"key": "value"}, group_by_file=True, page=1, page_size=10)
|
141
|
+
```
|
142
|
+
|
143
|
+
- `input` (str): The search query or input data.
|
144
|
+
- `modality` (str): The modality of the search (e.g., "text", "image", "video", "audio").
|
145
|
+
- `input_type` (str, optional): The type of input (default: "text").
|
146
|
+
- `filters` (dict, optional): Additional filters for the search.
|
147
|
+
- `group_by_file` (bool, optional): Whether to group results by file (default: True).
|
148
|
+
- `page` (int, optional): The page number for pagination (default: 1).
|
149
|
+
- `page_size` (int, optional): The number of results per page (default: 10).
|
150
|
+
|
151
|
+
#### Upload Search
|
152
|
+
|
153
|
+
```python
|
154
|
+
with open("query_image.jpg", "rb") as file:
|
155
|
+
response = client.search.upload(file=file, filters={"key": "value"}, page=1, page_size=10)
|
156
|
+
```
|
157
|
+
|
158
|
+
- `file` (file object): The file to use as a search query.
|
159
|
+
- `filters` (dict, optional): Additional filters for the search.
|
160
|
+
- `page` (int, optional): The page number for pagination (default: 1).
|
161
|
+
- `page_size` (int, optional): The number of results per page (default: 10).
|
162
|
+
|
163
|
+
#### URL Search
|
164
|
+
|
165
|
+
```python
|
166
|
+
response = client.search.url(url="https://example.com/image.jpg", input_type="file", filters={"key": "value"}, modality="image", page=1, page_size=10)
|
167
|
+
```
|
168
|
+
|
169
|
+
- `url` (str): The URL of the file to use as a search query.
|
170
|
+
- `input_type` (str, optional): The type of input (default: "file").
|
171
|
+
- `filters` (dict, optional): Additional filters for the search.
|
172
|
+
- `modality` (str, optional): The modality of the search (default: "text").
|
173
|
+
- `page` (int, optional): The page number for pagination (default: 1).
|
174
|
+
- `page_size` (int, optional): The number of results per page (default: 10).
|
175
|
+
|
176
|
+
### Collections
|
177
|
+
|
178
|
+
The `collections` module provides methods for managing collections and files.
|
179
|
+
|
180
|
+
#### List Files
|
181
|
+
|
182
|
+
```python
|
183
|
+
response = client.collections.list_files(collection_id="collection_id", randomize=False, page=1, page_size=10, filters={"key": "value"}, sort_by="created_at", sort_order="desc")
|
184
|
+
```
|
185
|
+
|
186
|
+
- `collection_id` (str): The ID of the collection to list files from.
|
187
|
+
- `randomize` (bool, optional): Whether to randomize the results (default: False).
|
188
|
+
- `page` (int, optional): The page number for pagination (default: 1).
|
189
|
+
- `page_size` (int, optional): The number of results per page (default: 10).
|
190
|
+
- `filters` (dict, optional): Additional filters for the file list.
|
191
|
+
- `sort_by` (str, optional): The field to sort by.
|
192
|
+
- `sort_order` (str, optional): The sort order, either "asc" or "desc" (default: "asc").
|
193
|
+
|
194
|
+
#### List Collections
|
195
|
+
|
196
|
+
```python
|
197
|
+
response = client.collections.list_collections()
|
198
|
+
```
|
199
|
+
|
200
|
+
#### Search Files
|
201
|
+
|
202
|
+
```python
|
203
|
+
response = client.collections.search_files(query="search query", collection_id="collection_id", page=1, page_size=10, sort_by="relevance", sort_order="desc")
|
204
|
+
```
|
205
|
+
|
206
|
+
- `query` (str): The search query for files within the collection.
|
207
|
+
- `collection_id` (str): The ID of the collection to search in.
|
208
|
+
- `page` (int, optional): The page number for pagination (default: 1).
|
209
|
+
- `page_size` (int, optional): The number of results per page (default: 10).
|
210
|
+
- `sort_by` (str, optional): The field to sort by.
|
211
|
+
- `sort_order` (str, optional): The sort order, either "asc" or "desc" (default: "asc").
|
212
|
+
|
213
|
+
#### Get File by ID
|
214
|
+
|
215
|
+
```python
|
216
|
+
response = client.collections.get_file_by_id(file_id="file_id")
|
217
|
+
```
|
218
|
+
|
219
|
+
- `file_id` (str): The ID of the file to retrieve.
|
220
|
+
|
221
|
+
#### Delete File by ID
|
222
|
+
|
223
|
+
```python
|
224
|
+
response = client.collections.delete_file_by_id(file_id="file_id")
|
225
|
+
```
|
226
|
+
|
227
|
+
- `file_id` (str): The ID of the file to delete.
|
228
|
+
|
229
|
+
#### Delete Collection
|
230
|
+
|
231
|
+
```python
|
232
|
+
response = client.collections.delete_collection(collection_id="collection_id")
|
233
|
+
```
|
234
|
+
|
235
|
+
- `collection_id` (str): The ID of the collection to delete.
|
236
|
+
|
237
|
+
### Tools
|
238
|
+
|
239
|
+
The `tools` module provides utility functions for processing various types of data before embedding or indexing.
|
240
|
+
|
241
|
+
#### Video Processing
|
242
|
+
|
243
|
+
The `video` tool allows you to process video files or URLs into chunks for easier embedding.
|
244
|
+
|
245
|
+
```python
|
246
|
+
from mixpeek import Mixpeek
|
247
|
+
|
248
|
+
mixpeek = Mixpeek('your_api_key_here')
|
249
|
+
|
250
|
+
video_url = "https://example.com/video.mp4"
|
251
|
+
|
252
|
+
# Process video chunks, this runs locally
|
253
|
+
processed_chunks = mixpeek.tools.video.process(
|
254
|
+
video_source=video_url,
|
255
|
+
chunk_interval=1,
|
256
|
+
resolution=[720, 1280]
|
257
|
+
)
|
258
|
+
|
259
|
+
# Embed each chunk
|
260
|
+
results = []
|
261
|
+
for index, chunk in enumerate(processed_chunks):
|
262
|
+
print(f"Processing video chunk: {index}")
|
263
|
+
|
264
|
+
embedding = mixpeek.embed.video(
|
265
|
+
model_id="vuse-generic-v1",
|
266
|
+
input=chunk['base64_chunk'],
|
267
|
+
input_type="base64"
|
268
|
+
)['embedding']
|
269
|
+
|
270
|
+
result = {
|
271
|
+
"start_time": chunk["start_time"],
|
272
|
+
"end_time": chunk["end_time"],
|
273
|
+
"embedding": embedding
|
274
|
+
}
|
275
|
+
results.append(result)
|
276
|
+
print(f" Embedding preview: {embedding[:5] + ['...'] + embedding[-5:]}")
|
277
|
+
print("Insert into DB here")
|
278
|
+
|
279
|
+
print(f"Processed {len(results)} chunks")
|
280
|
+
```
|
281
|
+
|
282
|
+
Parameters for `mixpeek.tools.video.process`:
|
283
|
+
|
284
|
+
- `video_source` (str): URL or file path of the video to process.
|
285
|
+
- `chunk_interval` (float): Duration of each video chunk in seconds.
|
286
|
+
- `resolution` (list): Desired resolution of the video chunks as [height, width].
|
287
|
+
|
288
|
+
The `process` method returns a list of dictionaries, each containing:
|
289
|
+
|
290
|
+
- `start_time` (float): Start time of the chunk in seconds.
|
291
|
+
- `end_time` (float): End time of the chunk in seconds.
|
292
|
+
- `base64_chunk` (str): Base64-encoded video chunk.
|
293
|
+
|
294
|
+
This tool is particularly useful when you need to embed long videos, as it allows you to process the video in smaller chunks and embed each chunk separately.
|
295
|
+
|
296
|
+
### Register
|
297
|
+
|
298
|
+
The `register` module provides methods for registering various types of data, such as faces for facial recognition.
|
299
|
+
|
300
|
+
#### Face Registration
|
301
|
+
|
302
|
+
```python
|
303
|
+
from mixpeek import Mixpeek
|
304
|
+
|
305
|
+
# Initialize the Mixpeek client
|
306
|
+
mixpeek = Mixpeek(api_key="your_api_key_here")
|
307
|
+
|
308
|
+
# Path to the local image file containing faces
|
309
|
+
face_image_path = "/path/to/your/face_image.jpg"
|
310
|
+
|
311
|
+
# Start the face registration task
|
312
|
+
task = mixpeek.register.faces(
|
313
|
+
file_path=face_image_path,
|
314
|
+
collection_id="face-recognition-collection",
|
315
|
+
metadata={"name": "John Doe", "age": 30},
|
316
|
+
settings={"detection_threshold": 0.8}
|
317
|
+
)
|
318
|
+
|
319
|
+
# Define a callback function (optional)
|
320
|
+
def on_task_update(status):
|
321
|
+
print(f"Current task status: {status}")
|
322
|
+
|
323
|
+
# Wait for the task to complete
|
324
|
+
status = task.wait_for_done(
|
325
|
+
sleep_interval=1,
|
326
|
+
callback=on_task_update
|
327
|
+
)
|
328
|
+
|
329
|
+
print(f"Face registration completed with status: {status}")
|
330
|
+
|
331
|
+
# If you want to do something with the final result
|
332
|
+
if status.get("status") == "DONE":
|
333
|
+
result = status.get("result")
|
334
|
+
print("Face registration result:", result)
|
335
|
+
else:
|
336
|
+
print("Face registration failed or was interrupted")
|
337
|
+
```
|
338
|
+
|
339
|
+
Parameters for `mixpeek.register.faces`:
|
340
|
+
|
341
|
+
- `file_path` (str): Path to the local image file containing faces to register.
|
342
|
+
- `collection_id` (str): The ID of the collection to add the registered faces to.
|
343
|
+
- `metadata` (dict, optional): Additional metadata for the registered faces.
|
344
|
+
- `settings` (dict, optional): Processing settings for face registration.
|
345
|
+
|
346
|
+
The `faces` method returns a `Task` object that allows you to monitor the progress of the face registration process.
|
347
|
+
|
348
|
+
## Response Format
|
349
|
+
|
350
|
+
All methods return a JSON response. In case of an error, the response will contain an "error" key with a description of the error.
|
351
|
+
|
352
|
+
## Error Handling
|
353
|
+
|
354
|
+
The SDK handles HTTP errors and returns them in the response. You should always check for the presence of an "error" key in the response before processing the results.
|
355
|
+
|
356
|
+
```python
|
357
|
+
response = client.embed.text(model_id="model_id", input="text_to_embed", input_type="text")
|
358
|
+
if "error" in response:
|
359
|
+
print(f"An error occurred: {response['error']}")
|
360
|
+
else:
|
361
|
+
# Process the successful response
|
362
|
+
print(response)
|
363
|
+
```
|
364
|
+
|
365
|
+
## Rate Limiting
|
366
|
+
|
367
|
+
The Mixpeek API may have rate limits. If you encounter rate limiting errors, you should implement appropriate backoff and retry logic in your application.
|
368
|
+
|
369
|
+
## Support
|
370
|
+
|
371
|
+
For any issues or questions, please contact Mixpeek support or refer to the official API documentation.
|
372
|
+
|
373
|
+
```
|
374
|
+
|
375
|
+
```
|