mixpeek 0.6.29__tar.gz → 0.7.0__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.
Files changed (31) hide show
  1. mixpeek-0.7.0/PKG-INFO +324 -0
  2. mixpeek-0.7.0/README.md +307 -0
  3. mixpeek-0.7.0/mixpeek/client.py +25 -0
  4. mixpeek-0.7.0/mixpeek/endpoints/collections.py +77 -0
  5. mixpeek-0.7.0/mixpeek/endpoints/embed.py +66 -0
  6. mixpeek-0.7.0/mixpeek/endpoints/index.py +51 -0
  7. mixpeek-0.7.0/mixpeek/endpoints/search.py +60 -0
  8. mixpeek-0.7.0/mixpeek/endpoints/tools.py +106 -0
  9. mixpeek-0.7.0/mixpeek.egg-info/PKG-INFO +324 -0
  10. {mixpeek-0.6.29 → mixpeek-0.7.0}/mixpeek.egg-info/SOURCES.txt +3 -4
  11. mixpeek-0.7.0/mixpeek.egg-info/requires.txt +4 -0
  12. mixpeek-0.6.29/mixpeek.egg-info/requires.txt → mixpeek-0.7.0/requirements.txt +2 -0
  13. {mixpeek-0.6.29 → mixpeek-0.7.0}/setup.py +1 -1
  14. mixpeek-0.6.29/PKG-INFO +0 -122
  15. mixpeek-0.6.29/README.md +0 -107
  16. mixpeek-0.6.29/mixpeek/client.py +0 -26
  17. mixpeek-0.6.29/mixpeek/endpoints/connections.py +0 -71
  18. mixpeek-0.6.29/mixpeek/endpoints/embed.py +0 -50
  19. mixpeek-0.6.29/mixpeek/endpoints/extract.py +0 -55
  20. mixpeek-0.6.29/mixpeek/endpoints/generate.py +0 -17
  21. mixpeek-0.6.29/mixpeek/endpoints/pipelines.py +0 -37
  22. mixpeek-0.6.29/mixpeek/endpoints/tools.py +0 -24
  23. mixpeek-0.6.29/mixpeek.egg-info/PKG-INFO +0 -122
  24. mixpeek-0.6.29/requirements.txt +0 -2
  25. {mixpeek-0.6.29 → mixpeek-0.7.0}/MANIFEST.in +0 -0
  26. {mixpeek-0.6.29 → mixpeek-0.7.0}/mixpeek/__init__.py +0 -0
  27. {mixpeek-0.6.29 → mixpeek-0.7.0}/mixpeek/endpoints/__init__.py +0 -0
  28. {mixpeek-0.6.29 → mixpeek-0.7.0}/mixpeek/exceptions.py +0 -0
  29. {mixpeek-0.6.29 → mixpeek-0.7.0}/mixpeek.egg-info/dependency_links.txt +0 -0
  30. {mixpeek-0.6.29 → mixpeek-0.7.0}/mixpeek.egg-info/top_level.txt +0 -0
  31. {mixpeek-0.6.29 → mixpeek-0.7.0}/setup.cfg +0 -0
mixpeek-0.7.0/PKG-INFO ADDED
@@ -0,0 +1,324 @@
1
+ Metadata-Version: 2.1
2
+ Name: mixpeek
3
+ Version: 0.7.0
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
+
18
+ # Mixpeek Python SDK
19
+
20
+ This SDK provides easy access to the Mixpeek API for Python developers.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install mixpeek
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ First, import and initialize the Mixpeek client:
31
+
32
+ ```python
33
+ from mixpeek import Mixpeek
34
+
35
+ client = Mixpeek(api_key="your_api_key_here")
36
+ ```
37
+
38
+ ### Embed
39
+
40
+ The `embed` module provides methods for embedding various types of data.
41
+
42
+ #### Video Embedding
43
+
44
+ ```python
45
+ response = client.embed.video(model_id="model_id", input="video_data", input_type="base64")
46
+ ```
47
+
48
+ - `model_id` (str): The ID of the model to use for embedding.
49
+ - `input` (str): The video data or URL.
50
+ - `input_type` (str): Either "base64" or "url".
51
+
52
+ #### Text Embedding
53
+
54
+ ```python
55
+ response = client.embed.text(model_id="model_id", input="text_to_embed", input_type="text")
56
+ ```
57
+
58
+ - `model_id` (str): The ID of the model to use for embedding.
59
+ - `input` (str): The text to embed.
60
+ - `input_type` (str): Should be "text".
61
+
62
+ #### Image Embedding
63
+
64
+ ```python
65
+ response = client.embed.image(model_id="model_id", input="image_data", input_type="base64")
66
+ ```
67
+
68
+ - `model_id` (str): The ID of the model to use for embedding.
69
+ - `input` (str): The image data or URL.
70
+ - `input_type` (str): Either "base64" or "url".
71
+
72
+ #### Audio Embedding
73
+
74
+ ```python
75
+ response = client.embed.audio(model_id="model_id", input="audio_data", input_type="base64")
76
+ ```
77
+
78
+ - `model_id` (str): The ID of the model to use for embedding.
79
+ - `input` (str): The audio data or URL.
80
+ - `input_type` (str): Either "base64" or "url".
81
+
82
+ ### Index
83
+
84
+ The `index` module provides methods for indexing various types of content.
85
+
86
+ #### Upload File
87
+
88
+ ```python
89
+ with open("file.txt", "rb") as file:
90
+ response = client.index.upload(file=file, collection_id="collection_id", metadata={"key": "value"}, settings={"video": {"transcribe": True}})
91
+ ```
92
+
93
+ - `file` (file object): The file to upload.
94
+ - `collection_id` (str): The ID of the collection to add the file to.
95
+ - `metadata` (dict, optional): Additional metadata for the file.
96
+ - `settings` (dict, optional): Processing settings for the file.
97
+
98
+ #### Index URL
99
+
100
+ ```python
101
+ response = client.index.url(url="https://example.com", collection_id="collection_id", metadata={"key": "value"}, settings={"image": {"caption_model_id": "model_id"}})
102
+ ```
103
+
104
+ - `url` (str): The URL to index.
105
+ - `collection_id` (str): The ID of the collection to add the content to.
106
+ - `metadata` (dict, optional): Additional metadata for the content.
107
+ - `settings` (dict, optional): Processing settings for the content.
108
+
109
+ #### Index YouTube Video
110
+
111
+ ```python
112
+ response = client.index.youtube(youtube_video_id="video_id", collection_id="collection_id", metadata={"key": "value"}, settings={"video": {"transcribe": True}})
113
+ ```
114
+
115
+ - `youtube_video_id` (str): The ID of the YouTube video to index.
116
+ - `collection_id` (str): The ID of the collection to add the video to.
117
+ - `metadata` (dict, optional): Additional metadata for the video.
118
+ - `settings` (dict, optional): Processing settings for the video.
119
+
120
+ #### Search YouTube
121
+
122
+ ```python
123
+ response = client.index.youtube_search(query="search query", collection_id="collection_id", max_results=20, metadata={"key": "value"}, shorts_only=False)
124
+ ```
125
+
126
+ - `query` (str): The search query for YouTube videos.
127
+ - `collection_id` (str): The ID of the collection to add the search results to.
128
+ - `max_results` (int, optional): Maximum number of results to return (default: 10, max: 500).
129
+ - `metadata` (dict, optional): Additional metadata for the search results.
130
+ - `shorts_only` (bool, optional): Whether to search for YouTube Shorts only (default: False).
131
+
132
+ ### Search
133
+
134
+ The `search` module provides methods for searching indexed content.
135
+
136
+ #### Text Search
137
+
138
+ ```python
139
+ response = client.search.text(input="search query", modality="text", input_type="text", filters={"key": "value"}, group_by_file=True, page=1, page_size=10)
140
+ ```
141
+
142
+ - `input` (str): The search query or input data.
143
+ - `modality` (str): The modality of the search (e.g., "text", "image", "video", "audio").
144
+ - `input_type` (str, optional): The type of input (default: "text").
145
+ - `filters` (dict, optional): Additional filters for the search.
146
+ - `group_by_file` (bool, optional): Whether to group results by file (default: True).
147
+ - `page` (int, optional): The page number for pagination (default: 1).
148
+ - `page_size` (int, optional): The number of results per page (default: 10).
149
+
150
+ #### Upload Search
151
+
152
+ ```python
153
+ with open("query_image.jpg", "rb") as file:
154
+ response = client.search.upload(file=file, filters={"key": "value"}, page=1, page_size=10)
155
+ ```
156
+
157
+ - `file` (file object): The file to use as a search query.
158
+ - `filters` (dict, optional): Additional filters for the search.
159
+ - `page` (int, optional): The page number for pagination (default: 1).
160
+ - `page_size` (int, optional): The number of results per page (default: 10).
161
+
162
+ #### URL Search
163
+
164
+ ```python
165
+ response = client.search.url(url="https://example.com/image.jpg", input_type="file", filters={"key": "value"}, modality="image", page=1, page_size=10)
166
+ ```
167
+
168
+ - `url` (str): The URL of the file to use as a search query.
169
+ - `input_type` (str, optional): The type of input (default: "file").
170
+ - `filters` (dict, optional): Additional filters for the search.
171
+ - `modality` (str, optional): The modality of the search (default: "text").
172
+ - `page` (int, optional): The page number for pagination (default: 1).
173
+ - `page_size` (int, optional): The number of results per page (default: 10).
174
+
175
+ ### Collections
176
+
177
+ The `collections` module provides methods for managing collections and files.
178
+
179
+ #### List Files
180
+
181
+ ```python
182
+ 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")
183
+ ```
184
+
185
+ - `collection_id` (str): The ID of the collection to list files from.
186
+ - `randomize` (bool, optional): Whether to randomize the results (default: False).
187
+ - `page` (int, optional): The page number for pagination (default: 1).
188
+ - `page_size` (int, optional): The number of results per page (default: 10).
189
+ - `filters` (dict, optional): Additional filters for the file list.
190
+ - `sort_by` (str, optional): The field to sort by.
191
+ - `sort_order` (str, optional): The sort order, either "asc" or "desc" (default: "asc").
192
+
193
+ #### List Collections
194
+
195
+ ```python
196
+ response = client.collections.list_collections()
197
+ ```
198
+
199
+ #### Search Files
200
+
201
+ ```python
202
+ response = client.collections.search_files(query="search query", collection_id="collection_id", page=1, page_size=10, sort_by="relevance", sort_order="desc")
203
+ ```
204
+
205
+ - `query` (str): The search query for files within the collection.
206
+ - `collection_id` (str): The ID of the collection to search in.
207
+ - `page` (int, optional): The page number for pagination (default: 1).
208
+ - `page_size` (int, optional): The number of results per page (default: 10).
209
+ - `sort_by` (str, optional): The field to sort by.
210
+ - `sort_order` (str, optional): The sort order, either "asc" or "desc" (default: "asc").
211
+
212
+ #### Get File by ID
213
+
214
+ ```python
215
+ response = client.collections.get_file_by_id(file_id="file_id")
216
+ ```
217
+
218
+ - `file_id` (str): The ID of the file to retrieve.
219
+
220
+ #### Delete File by ID
221
+
222
+ ```python
223
+ response = client.collections.delete_file_by_id(file_id="file_id")
224
+ ```
225
+
226
+ - `file_id` (str): The ID of the file to delete.
227
+
228
+ #### Delete Collection
229
+
230
+ ```python
231
+ response = client.collections.delete_collection(collection_id="collection_id")
232
+ ```
233
+
234
+ - `collection_id` (str): The ID of the collection to delete.
235
+
236
+ Certainly! I'll update the README to include information about the `tools` service, specifically the video processing functionality. Here's the addition to the README:
237
+
238
+ ### Tools
239
+
240
+ The `tools` module provides utility functions for processing various types of data before embedding or indexing.
241
+
242
+ #### Video Processing
243
+
244
+ The `video` tool allows you to process video files or URLs into chunks for easier embedding.
245
+
246
+ ```python
247
+ from mixpeek import Mixpeek
248
+
249
+ mixpeek = Mixpeek('your_api_key_here')
250
+
251
+ video_url = "https://example.com/video.mp4"
252
+
253
+ # Process video chunks, this runs locally
254
+ processed_chunks = mixpeek.tools.video.process(
255
+ video_source=video_url,
256
+ chunk_interval=1,
257
+ resolution=[720, 1280]
258
+ )
259
+
260
+ # Embed each chunk
261
+ results = []
262
+ for index, chunk in enumerate(processed_chunks):
263
+ print(f"Processing video chunk: {index}")
264
+
265
+ embedding = mixpeek.embed.video(
266
+ model_id="vuse-generic-v1",
267
+ input=chunk['base64_chunk'],
268
+ input_type="base64"
269
+ )['embedding']
270
+
271
+ result = {
272
+ "start_time": chunk["start_time"],
273
+ "end_time": chunk["end_time"],
274
+ "embedding": embedding
275
+ }
276
+ results.append(result)
277
+ print(f" Embedding preview: {embedding[:5] + ['...'] + embedding[-5:]}")
278
+ print("Insert into DB here")
279
+
280
+ print(f"Processed {len(results)} chunks")
281
+ ```
282
+
283
+ Parameters for `mixpeek.tools.video.process`:
284
+
285
+ - `video_source` (str): URL or file path of the video to process.
286
+ - `chunk_interval` (float): Duration of each video chunk in seconds.
287
+ - `resolution` (list): Desired resolution of the video chunks as [height, width].
288
+
289
+ The `process` method returns a list of dictionaries, each containing:
290
+
291
+ - `start_time` (float): Start time of the chunk in seconds.
292
+ - `end_time` (float): End time of the chunk in seconds.
293
+ - `base64_chunk` (str): Base64-encoded video chunk.
294
+
295
+ 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.
296
+
297
+ ## Response Format
298
+
299
+ All methods return a JSON response. In case of an error, the response will contain an "error" key with a description of the error.
300
+
301
+ ## Error Handling
302
+
303
+ 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.
304
+
305
+ ```python
306
+ response = client.embed.text(model_id="model_id", input="text_to_embed", input_type="text")
307
+ if "error" in response:
308
+ print(f"An error occurred: {response['error']}")
309
+ else:
310
+ # Process the successful response
311
+ print(response)
312
+ ```
313
+
314
+ ## Rate Limiting
315
+
316
+ The Mixpeek API may have rate limits. If you encounter rate limiting errors, you should implement appropriate backoff and retry logic in your application.
317
+
318
+ ## Support
319
+
320
+ For any issues or questions, please contact Mixpeek support or refer to the official API documentation.
321
+
322
+ ```
323
+
324
+ ```
@@ -0,0 +1,307 @@
1
+ # Mixpeek Python SDK
2
+
3
+ This SDK provides easy access to the Mixpeek API for Python developers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install mixpeek
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ First, import and initialize the Mixpeek client:
14
+
15
+ ```python
16
+ from mixpeek import Mixpeek
17
+
18
+ client = Mixpeek(api_key="your_api_key_here")
19
+ ```
20
+
21
+ ### Embed
22
+
23
+ The `embed` module provides methods for embedding various types of data.
24
+
25
+ #### Video Embedding
26
+
27
+ ```python
28
+ response = client.embed.video(model_id="model_id", input="video_data", input_type="base64")
29
+ ```
30
+
31
+ - `model_id` (str): The ID of the model to use for embedding.
32
+ - `input` (str): The video data or URL.
33
+ - `input_type` (str): Either "base64" or "url".
34
+
35
+ #### Text Embedding
36
+
37
+ ```python
38
+ response = client.embed.text(model_id="model_id", input="text_to_embed", input_type="text")
39
+ ```
40
+
41
+ - `model_id` (str): The ID of the model to use for embedding.
42
+ - `input` (str): The text to embed.
43
+ - `input_type` (str): Should be "text".
44
+
45
+ #### Image Embedding
46
+
47
+ ```python
48
+ response = client.embed.image(model_id="model_id", input="image_data", input_type="base64")
49
+ ```
50
+
51
+ - `model_id` (str): The ID of the model to use for embedding.
52
+ - `input` (str): The image data or URL.
53
+ - `input_type` (str): Either "base64" or "url".
54
+
55
+ #### Audio Embedding
56
+
57
+ ```python
58
+ response = client.embed.audio(model_id="model_id", input="audio_data", input_type="base64")
59
+ ```
60
+
61
+ - `model_id` (str): The ID of the model to use for embedding.
62
+ - `input` (str): The audio data or URL.
63
+ - `input_type` (str): Either "base64" or "url".
64
+
65
+ ### Index
66
+
67
+ The `index` module provides methods for indexing various types of content.
68
+
69
+ #### Upload File
70
+
71
+ ```python
72
+ with open("file.txt", "rb") as file:
73
+ response = client.index.upload(file=file, collection_id="collection_id", metadata={"key": "value"}, settings={"video": {"transcribe": True}})
74
+ ```
75
+
76
+ - `file` (file object): The file to upload.
77
+ - `collection_id` (str): The ID of the collection to add the file to.
78
+ - `metadata` (dict, optional): Additional metadata for the file.
79
+ - `settings` (dict, optional): Processing settings for the file.
80
+
81
+ #### Index URL
82
+
83
+ ```python
84
+ response = client.index.url(url="https://example.com", collection_id="collection_id", metadata={"key": "value"}, settings={"image": {"caption_model_id": "model_id"}})
85
+ ```
86
+
87
+ - `url` (str): The URL to index.
88
+ - `collection_id` (str): The ID of the collection to add the content to.
89
+ - `metadata` (dict, optional): Additional metadata for the content.
90
+ - `settings` (dict, optional): Processing settings for the content.
91
+
92
+ #### Index YouTube Video
93
+
94
+ ```python
95
+ response = client.index.youtube(youtube_video_id="video_id", collection_id="collection_id", metadata={"key": "value"}, settings={"video": {"transcribe": True}})
96
+ ```
97
+
98
+ - `youtube_video_id` (str): The ID of the YouTube video to index.
99
+ - `collection_id` (str): The ID of the collection to add the video to.
100
+ - `metadata` (dict, optional): Additional metadata for the video.
101
+ - `settings` (dict, optional): Processing settings for the video.
102
+
103
+ #### Search YouTube
104
+
105
+ ```python
106
+ response = client.index.youtube_search(query="search query", collection_id="collection_id", max_results=20, metadata={"key": "value"}, shorts_only=False)
107
+ ```
108
+
109
+ - `query` (str): The search query for YouTube videos.
110
+ - `collection_id` (str): The ID of the collection to add the search results to.
111
+ - `max_results` (int, optional): Maximum number of results to return (default: 10, max: 500).
112
+ - `metadata` (dict, optional): Additional metadata for the search results.
113
+ - `shorts_only` (bool, optional): Whether to search for YouTube Shorts only (default: False).
114
+
115
+ ### Search
116
+
117
+ The `search` module provides methods for searching indexed content.
118
+
119
+ #### Text Search
120
+
121
+ ```python
122
+ response = client.search.text(input="search query", modality="text", input_type="text", filters={"key": "value"}, group_by_file=True, page=1, page_size=10)
123
+ ```
124
+
125
+ - `input` (str): The search query or input data.
126
+ - `modality` (str): The modality of the search (e.g., "text", "image", "video", "audio").
127
+ - `input_type` (str, optional): The type of input (default: "text").
128
+ - `filters` (dict, optional): Additional filters for the search.
129
+ - `group_by_file` (bool, optional): Whether to group results by file (default: True).
130
+ - `page` (int, optional): The page number for pagination (default: 1).
131
+ - `page_size` (int, optional): The number of results per page (default: 10).
132
+
133
+ #### Upload Search
134
+
135
+ ```python
136
+ with open("query_image.jpg", "rb") as file:
137
+ response = client.search.upload(file=file, filters={"key": "value"}, page=1, page_size=10)
138
+ ```
139
+
140
+ - `file` (file object): The file to use as a search query.
141
+ - `filters` (dict, optional): Additional filters for the search.
142
+ - `page` (int, optional): The page number for pagination (default: 1).
143
+ - `page_size` (int, optional): The number of results per page (default: 10).
144
+
145
+ #### URL Search
146
+
147
+ ```python
148
+ response = client.search.url(url="https://example.com/image.jpg", input_type="file", filters={"key": "value"}, modality="image", page=1, page_size=10)
149
+ ```
150
+
151
+ - `url` (str): The URL of the file to use as a search query.
152
+ - `input_type` (str, optional): The type of input (default: "file").
153
+ - `filters` (dict, optional): Additional filters for the search.
154
+ - `modality` (str, optional): The modality of the search (default: "text").
155
+ - `page` (int, optional): The page number for pagination (default: 1).
156
+ - `page_size` (int, optional): The number of results per page (default: 10).
157
+
158
+ ### Collections
159
+
160
+ The `collections` module provides methods for managing collections and files.
161
+
162
+ #### List Files
163
+
164
+ ```python
165
+ 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")
166
+ ```
167
+
168
+ - `collection_id` (str): The ID of the collection to list files from.
169
+ - `randomize` (bool, optional): Whether to randomize the results (default: False).
170
+ - `page` (int, optional): The page number for pagination (default: 1).
171
+ - `page_size` (int, optional): The number of results per page (default: 10).
172
+ - `filters` (dict, optional): Additional filters for the file list.
173
+ - `sort_by` (str, optional): The field to sort by.
174
+ - `sort_order` (str, optional): The sort order, either "asc" or "desc" (default: "asc").
175
+
176
+ #### List Collections
177
+
178
+ ```python
179
+ response = client.collections.list_collections()
180
+ ```
181
+
182
+ #### Search Files
183
+
184
+ ```python
185
+ response = client.collections.search_files(query="search query", collection_id="collection_id", page=1, page_size=10, sort_by="relevance", sort_order="desc")
186
+ ```
187
+
188
+ - `query` (str): The search query for files within the collection.
189
+ - `collection_id` (str): The ID of the collection to search in.
190
+ - `page` (int, optional): The page number for pagination (default: 1).
191
+ - `page_size` (int, optional): The number of results per page (default: 10).
192
+ - `sort_by` (str, optional): The field to sort by.
193
+ - `sort_order` (str, optional): The sort order, either "asc" or "desc" (default: "asc").
194
+
195
+ #### Get File by ID
196
+
197
+ ```python
198
+ response = client.collections.get_file_by_id(file_id="file_id")
199
+ ```
200
+
201
+ - `file_id` (str): The ID of the file to retrieve.
202
+
203
+ #### Delete File by ID
204
+
205
+ ```python
206
+ response = client.collections.delete_file_by_id(file_id="file_id")
207
+ ```
208
+
209
+ - `file_id` (str): The ID of the file to delete.
210
+
211
+ #### Delete Collection
212
+
213
+ ```python
214
+ response = client.collections.delete_collection(collection_id="collection_id")
215
+ ```
216
+
217
+ - `collection_id` (str): The ID of the collection to delete.
218
+
219
+ Certainly! I'll update the README to include information about the `tools` service, specifically the video processing functionality. Here's the addition to the README:
220
+
221
+ ### Tools
222
+
223
+ The `tools` module provides utility functions for processing various types of data before embedding or indexing.
224
+
225
+ #### Video Processing
226
+
227
+ The `video` tool allows you to process video files or URLs into chunks for easier embedding.
228
+
229
+ ```python
230
+ from mixpeek import Mixpeek
231
+
232
+ mixpeek = Mixpeek('your_api_key_here')
233
+
234
+ video_url = "https://example.com/video.mp4"
235
+
236
+ # Process video chunks, this runs locally
237
+ processed_chunks = mixpeek.tools.video.process(
238
+ video_source=video_url,
239
+ chunk_interval=1,
240
+ resolution=[720, 1280]
241
+ )
242
+
243
+ # Embed each chunk
244
+ results = []
245
+ for index, chunk in enumerate(processed_chunks):
246
+ print(f"Processing video chunk: {index}")
247
+
248
+ embedding = mixpeek.embed.video(
249
+ model_id="vuse-generic-v1",
250
+ input=chunk['base64_chunk'],
251
+ input_type="base64"
252
+ )['embedding']
253
+
254
+ result = {
255
+ "start_time": chunk["start_time"],
256
+ "end_time": chunk["end_time"],
257
+ "embedding": embedding
258
+ }
259
+ results.append(result)
260
+ print(f" Embedding preview: {embedding[:5] + ['...'] + embedding[-5:]}")
261
+ print("Insert into DB here")
262
+
263
+ print(f"Processed {len(results)} chunks")
264
+ ```
265
+
266
+ Parameters for `mixpeek.tools.video.process`:
267
+
268
+ - `video_source` (str): URL or file path of the video to process.
269
+ - `chunk_interval` (float): Duration of each video chunk in seconds.
270
+ - `resolution` (list): Desired resolution of the video chunks as [height, width].
271
+
272
+ The `process` method returns a list of dictionaries, each containing:
273
+
274
+ - `start_time` (float): Start time of the chunk in seconds.
275
+ - `end_time` (float): End time of the chunk in seconds.
276
+ - `base64_chunk` (str): Base64-encoded video chunk.
277
+
278
+ 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.
279
+
280
+ ## Response Format
281
+
282
+ All methods return a JSON response. In case of an error, the response will contain an "error" key with a description of the error.
283
+
284
+ ## Error Handling
285
+
286
+ 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.
287
+
288
+ ```python
289
+ response = client.embed.text(model_id="model_id", input="text_to_embed", input_type="text")
290
+ if "error" in response:
291
+ print(f"An error occurred: {response['error']}")
292
+ else:
293
+ # Process the successful response
294
+ print(response)
295
+ ```
296
+
297
+ ## Rate Limiting
298
+
299
+ The Mixpeek API may have rate limits. If you encounter rate limiting errors, you should implement appropriate backoff and retry logic in your application.
300
+
301
+ ## Support
302
+
303
+ For any issues or questions, please contact Mixpeek support or refer to the official API documentation.
304
+
305
+ ```
306
+
307
+ ```
@@ -0,0 +1,25 @@
1
+ import requests
2
+
3
+ from .endpoints.embed import Embed
4
+ from .endpoints.collections import Collections
5
+ from .endpoints.index import Index
6
+ from .endpoints.search import Search
7
+ from .endpoints.tools import Tools
8
+
9
+
10
+ class Mixpeek:
11
+ def __init__(self, api_key: str):
12
+ self.api_key = api_key
13
+ self.base_url = "https://api.mixpeek.com/"
14
+ self.headers = {
15
+ "Authorization": f"Bearer {self.api_key}",
16
+ "Content-Type": "application/json"
17
+ }
18
+ # these are remote
19
+ self.embed = Embed(self.base_url, self.headers)
20
+ self.collections = Collections(self.base_url, self.headers)
21
+ self.index = Index(self.base_url, self.headers)
22
+ self.search = Search(self.base_url, self.headers)
23
+
24
+ # tools is all local
25
+ self.tools = Tools()