mixpeek 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.
mixpeek/__init__.py ADDED
@@ -0,0 +1,73 @@
1
+ # mixpeek.py
2
+ import requests
3
+ import json
4
+
5
+
6
+ class Mixpeek:
7
+ def __init__(self, api_key):
8
+ self.base_url = "https://api.mixpeek.com"
9
+ self.headers = {
10
+ "Authorization": f"Bearer {api_key}",
11
+ "Content-Type": "application/json",
12
+ }
13
+ self.generate = self.Generate(self)
14
+ self.parse = self.Parse(self)
15
+
16
+ def _send_post(self, url, payload):
17
+ return requests.post(url, headers=self.headers, data=json.dumps(payload)).json()
18
+
19
+ def _send_get(self, url):
20
+ return requests.get(url, headers=self.headers).json()
21
+
22
+ class Generate:
23
+ def __init__(self, mixpeek):
24
+ self.mixpeek = mixpeek
25
+ self.openai = self.OpenAI(self.mixpeek)
26
+
27
+ class OpenAI:
28
+ def __init__(self, mixpeek):
29
+ self.mixpeek = mixpeek
30
+ self.generate_openai_url = f"{self.mixpeek.base_url}/generate"
31
+
32
+ def _construct_request_format(
33
+ self, model, context, response_format, settings=None
34
+ ):
35
+ payload = {
36
+ "model": {"provider": "gpt", "model": model},
37
+ "context": context,
38
+ "messages": [{"role": "user", "content": ""}],
39
+ **settings,
40
+ }
41
+
42
+ if response_format is not None:
43
+ json_schema = response_format.model_json_schema()
44
+ payload["response_format"] = json_schema
45
+
46
+ return payload
47
+
48
+ def chat(self, model, response_format, context, settings=None):
49
+ payload = self._construct_request_format(
50
+ model, context, response_format, settings
51
+ )
52
+ return self.mixpeek._send_post(self.generate_openai_url, payload)
53
+
54
+ class Parse:
55
+ def __init__(self, mixpeek):
56
+ self.mixpeek = mixpeek
57
+ self.text = self.Text(self.mixpeek)
58
+
59
+ class Text:
60
+ def __init__(self, mixpeek):
61
+ self.mixpeek = mixpeek
62
+ self.parse_url = f"{self.mixpeek.base_url}/parsers"
63
+
64
+ def extract(self, file_url, should_chunk=True):
65
+ url = self.parse_url + "?should_chunk=" + str(should_chunk)
66
+ return self.mixpeek._send_post(url, {"file_url": file_url})
67
+
68
+ def chunk(self, corpus):
69
+ pass
70
+
71
+ class Index:
72
+ def __init__(self):
73
+ pass
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2021 mixpeek
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
20
+ OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.1
2
+ Name: mixpeek
3
+ Version: 0.1.0
4
+ Summary:
5
+ Author: Ethan Steininger
6
+ Author-email: esteininger21@gmail.com
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Dist: pydantic (>=2.6.4,<3.0.0)
12
+ Requires-Dist: requests (>=2.31.0,<3.0.0)
13
+ Description-Content-Type: text/markdown
14
+
15
+ # Mixpeek
16
+
17
+ Mixpeek let's you run full-text-search on your files
18
+
19
+ **Stuff you might be looking for**:
20
+
21
+ - [API Documentation](https://docs.mixpeek.com)
22
+ - [Installing Mixpeek](https://github.com/mixpeek/mixpeek-python#installation)
23
+ - [S3 Support](https://github.com/mixpeek/mixpeek-python#s3-support)
24
+ - [Bugs & Questions](https://github.com/mixpeek/mixpeek-python#bugs-&-questions)
25
+
26
+ ## Quickstart
27
+
28
+ Upload any filetype from the supported filetype [list here](https://mixpeek.com/learn)
29
+
30
+ ```python
31
+ from mixpeek import Mixpeek
32
+
33
+ mix = Mixpeek(api_key="API_KEY")
34
+
35
+ # index one local pdf document without any extra metadata
36
+ mix.index("/user/desktop/file.pdf")
37
+
38
+ # with extra metadata
39
+ mix.index(
40
+ "/user/desktop/file.pdf",
41
+ user_id="123",
42
+ tags="document, legal",
43
+ static_file_url="cdn.host.com/file.pdf",
44
+ save=True,
45
+ description="this is a cat"
46
+ )
47
+ ```
48
+
49
+ ...or any audio filetype
50
+
51
+ ```python
52
+ mix.index("/user/desktop/never_gonna_give_you_up.mp3")
53
+ ```
54
+
55
+ ... or an image, video, document or [anything else mixpeek supports](https://mixpeek.com/learn)
56
+
57
+ ```python
58
+ video = mix.index("/user/desktop/video.avi")
59
+ image = mix.index("/user/desktop/image.png")
60
+ markdown = mix.index("/user/desktop/markdown.md")
61
+ ```
62
+
63
+ The API will return the `file_id`, be sure to store this:
64
+
65
+ ```python
66
+ # response
67
+ {
68
+ "file_id": "63a32cca0de5e4ce354a4b1c"
69
+ }
70
+ ```
71
+
72
+ Now you can search across all your files:
73
+
74
+ ```python
75
+ mix.search(query="let you down")
76
+
77
+ # response
78
+ [
79
+ {
80
+ "file_id": "6377c98b3c4f239f17663d79",
81
+ "filename": "prescription.pdf",
82
+ "importance": "100%",
83
+ "static_file_url": "s3://audio.mp3"
84
+ }
85
+ ]
86
+
87
+ ```
88
+
89
+ And you can include other parameters in your search query:
90
+
91
+ ```python
92
+ mix.search(
93
+ "readme",
94
+ user_id="john_smith_123",
95
+ context="true",
96
+ tags="legal, document"
97
+ )
98
+
99
+ # response
100
+ [
101
+ {
102
+ "file_id": "63a32cd70de5e4ce354a4b1f",
103
+ "filename": "system-design-primer.md",
104
+ "static_file_url": "s3://audio.mp3",
105
+ "user_id": "john_smith_123",
106
+ "tags":["legal", "document"],
107
+ "highlights": [
108
+ {
109
+ "texts": [
110
+ {
111
+ "type": "text",
112
+ "value": "- What is the expected "
113
+ },
114
+ {
115
+ "type": "hit",
116
+ "value": "read"
117
+ },
118
+ {
119
+ "type": "text",
120
+ "value": " to write ratio?\n\n"
121
+ }
122
+ ]
123
+ }
124
+ ],
125
+ "importance": "100%"
126
+ }
127
+ ]
128
+ ```
129
+
130
+ ## Installation
131
+
132
+ Installing mixpeek is easy
133
+
134
+ ```shell
135
+ pip install git+https://github.com/mixpeek/mixpeek-python.git@master
136
+ ```
137
+
138
+ ## S3 Support
139
+
140
+ Be sure you create an AWS access key/secret key combo with S3 bucket read permissions using [this guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).
141
+
142
+ Files are never stored on our servers, review our [security principles](https://mixpeek.com/security).
143
+
144
+ ```python
145
+ from mixpeek import Mixpeek
146
+
147
+ mix = Mixpeek(
148
+ api_key="mixpeek_api_key",
149
+ access_key="aws_access_key",
150
+ secret_key="aws_secret_key",
151
+ region="region"
152
+ )
153
+
154
+ mix.index_bucket("mixpeek-public-demo")
155
+
156
+ # response (list of File_ids)
157
+
158
+ {
159
+ "file_ids": [
160
+ "63a33611660c021b50271666",
161
+ "63a33611660c021b50271667",
162
+ "63a33611660c021b50271668",
163
+ "63a33613660c021b50271669"
164
+ ]
165
+ }
166
+
167
+ ```
168
+
169
+ ## Bugs & Questions
170
+
171
+ If this was helpful, please upvote [this StackOverflow comment](https://stackoverflow.com/a/69475102/5956579)
172
+
173
+ You can file bugs in our [github issues tracker](https://github.com/mixpeek/mixpeek-python/issues),
174
+ and ask any technical questions on
175
+ [Stack Overflow using the mixpeek tag](http://stackoverflow.com/questions/ask?tags=mixpeek).
176
+ We keep an eye on both.
177
+
178
+ ## 🚀 Features
179
+
180
+ - Supports for `Python 3.8` and higher.
181
+ - Full text search
182
+ - AWS S3 Integration
183
+ - Fuzzy text matching
184
+
185
+ ## Articles:
186
+
187
+ [Learning Center](https://mixpeek.com/learn)
188
+
189
+ ## License ([MIT License](http://opensource.org/licenses/mit-license.php))
190
+
191
+ Copyright © 2022 Mixpeek, https://mixpeek.com
192
+
193
+ Permission is hereby granted, free of charge, to any person obtaining
194
+ a copy of this software and associated documentation files (the
195
+ "Software"), to deal in the Software without restriction, including
196
+ without limitation the rights to use, copy, modify, merge, publish,
197
+ distribute, sublicense, and/or sell copies of the Software, and to
198
+ permit persons to whom the Software is furnished to do so, subject to
199
+ the following conditions:
200
+
201
+ The above copyright notice and this permission notice shall be
202
+ included in all copies or substantial portions of the Software.
203
+
204
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
205
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
206
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
207
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
208
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
209
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
210
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
211
+
@@ -0,0 +1,5 @@
1
+ mixpeek/__init__.py,sha256=4e_lxuzNX6tRmpdleC0BP2PCuDrQeIomlQjbmR4NUK4,2448
2
+ mixpeek-0.1.0.dist-info/LICENSE.rst,sha256=HHFCinDHL38osjHNrBgNZqExYuEWJ3hNZxzcr1mWWeo,1072
3
+ mixpeek-0.1.0.dist-info/METADATA,sha256=PqS5GtWG0NOu6youD1oE-w74F6cs532JNXdkT2omt8c,5587
4
+ mixpeek-0.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
5
+ mixpeek-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.9.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any