txtai.py 6.2.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.
- txtai.py-6.2.0/LICENSE +190 -0
- txtai.py-6.2.0/PKG-INFO +77 -0
- txtai.py-6.2.0/README.md +54 -0
- txtai.py-6.2.0/pyproject.toml +2 -0
- txtai.py-6.2.0/setup.cfg +4 -0
- txtai.py-6.2.0/setup.py +36 -0
- txtai.py-6.2.0/src/python/txtai/__init__.py +0 -0
- txtai.py-6.2.0/src/python/txtai/client/__init__.py +16 -0
- txtai.py-6.2.0/src/python/txtai/client/api.py +114 -0
- txtai.py-6.2.0/src/python/txtai/client/embeddings.py +182 -0
- txtai.py-6.2.0/src/python/txtai/client/extractor.py +25 -0
- txtai.py-6.2.0/src/python/txtai/client/labels.py +42 -0
- txtai.py-6.2.0/src/python/txtai/client/segmentation.py +37 -0
- txtai.py-6.2.0/src/python/txtai/client/similarity.py +43 -0
- txtai.py-6.2.0/src/python/txtai/client/summary.py +53 -0
- txtai.py-6.2.0/src/python/txtai/client/textractor.py +37 -0
- txtai.py-6.2.0/src/python/txtai/client/transcription.py +37 -0
- txtai.py-6.2.0/src/python/txtai/client/translation.py +53 -0
- txtai.py-6.2.0/src/python/txtai/client/workflow.py +25 -0
- txtai.py-6.2.0/src/python/txtai.py.egg-info/PKG-INFO +77 -0
- txtai.py-6.2.0/src/python/txtai.py.egg-info/SOURCES.txt +22 -0
- txtai.py-6.2.0/src/python/txtai.py.egg-info/dependency_links.txt +1 -0
- txtai.py-6.2.0/src/python/txtai.py.egg-info/requires.txt +1 -0
- txtai.py-6.2.0/src/python/txtai.py.egg-info/top_level.txt +1 -0
txtai.py-6.2.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2020- NeuML LLC
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
txtai.py-6.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: txtai.py
|
|
3
|
+
Version: 6.2.0
|
|
4
|
+
Summary: Python client for txtai
|
|
5
|
+
Home-page: https://github.com/neuml/txtai.py
|
|
6
|
+
Author: NeuML
|
|
7
|
+
License: Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
Project-URL: Documentation, https://github.com/neuml/txtai.py
|
|
9
|
+
Project-URL: Issue Tracker, https://github.com/neuml/txtai.py/issues
|
|
10
|
+
Project-URL: Source Code, https://github.com/neuml/txtai.py
|
|
11
|
+
Keywords: search embedding machine-learning nlp
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
18
|
+
Classifier: Topic :: Utilities
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: aiohttp>=3.8.1
|
|
23
|
+
|
|
24
|
+
<p align="center">
|
|
25
|
+
<img src="https://raw.githubusercontent.com/neuml/txtai/master/logo.png"/>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<b>Python client for txtai</b>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<a href="https://github.com/neuml/txtai.py/releases">
|
|
34
|
+
<img src="https://img.shields.io/github/release/neuml/txtai.py.svg?style=flat&color=success" alt="Version"/>
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://github.com/neuml/txtai.py/releases">
|
|
37
|
+
<img src="https://img.shields.io/github/release-date/neuml/txtai.py.svg?style=flat&color=blue" alt="GitHub Release Date"/>
|
|
38
|
+
</a>
|
|
39
|
+
<a href="https://github.com/neuml/txtai.py/issues">
|
|
40
|
+
<img src="https://img.shields.io/github/issues/neuml/txtai.py.svg?style=flat&color=success" alt="GitHub Issues"/>
|
|
41
|
+
</a>
|
|
42
|
+
<a href="https://github.com/neuml/txtai.py">
|
|
43
|
+
<img src="https://img.shields.io/github/last-commit/neuml/txtai.py.svg?style=flat&color=blue" alt="GitHub Last Commit"/>
|
|
44
|
+
</a>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
[txtai](https://github.com/neuml/txtai) is an all-in-one embeddings database for semantic search, LLM orchestration and language model workflows.
|
|
48
|
+
|
|
49
|
+
This repository contains Python bindings for the txtai API. This is a minimal dependency library for Python designed for use cases where txtai is running through the API. In all other cases, txtai should be installed directly.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
txtai.py can be installed via PyPI
|
|
53
|
+
|
|
54
|
+
pip install txtai.py
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
The examples directory has a series of examples that give an overview of txtai. See the list of examples below.
|
|
58
|
+
|
|
59
|
+
| Example | Description |
|
|
60
|
+
|:----------|:-------------|
|
|
61
|
+
| [Introducing txtai](https://github.com/neuml/txtai.py/blob/master/examples/embeddings.py) | Overview of the functionality provided by txtai |
|
|
62
|
+
| [Extractive QA with txtai](https://github.com/neuml/txtai.py/blob/master/examples/extractor.py) | Extractive question-answering with txtai |
|
|
63
|
+
| [Labeling with zero-shot classification](https://github.com/neuml/txtai.py/blob/master/examples/labels.py) | Labeling with zero-shot classification |
|
|
64
|
+
| [Pipelines and workflows](https://github.com/neuml/txtai.py/blob/master/examples/pipelines.py) | Pipelines and workflows |
|
|
65
|
+
|
|
66
|
+
txtai.py connects to a txtai api instance. See [this link](https://neuml.github.io/txtai/api/) for details on how to start a new api instance.
|
|
67
|
+
|
|
68
|
+
Once an api instance is running, do the following to run the examples.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
git clone https://github.com/neuml/txtai.py
|
|
72
|
+
cd txtai.py/examples
|
|
73
|
+
python embeddings.py
|
|
74
|
+
python extractor.py
|
|
75
|
+
python labels.py
|
|
76
|
+
python pipelines.py
|
|
77
|
+
```
|
txtai.py-6.2.0/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/neuml/txtai/master/logo.png"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<b>Python client for txtai</b>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/neuml/txtai.py/releases">
|
|
11
|
+
<img src="https://img.shields.io/github/release/neuml/txtai.py.svg?style=flat&color=success" alt="Version"/>
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/neuml/txtai.py/releases">
|
|
14
|
+
<img src="https://img.shields.io/github/release-date/neuml/txtai.py.svg?style=flat&color=blue" alt="GitHub Release Date"/>
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://github.com/neuml/txtai.py/issues">
|
|
17
|
+
<img src="https://img.shields.io/github/issues/neuml/txtai.py.svg?style=flat&color=success" alt="GitHub Issues"/>
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/neuml/txtai.py">
|
|
20
|
+
<img src="https://img.shields.io/github/last-commit/neuml/txtai.py.svg?style=flat&color=blue" alt="GitHub Last Commit"/>
|
|
21
|
+
</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
[txtai](https://github.com/neuml/txtai) is an all-in-one embeddings database for semantic search, LLM orchestration and language model workflows.
|
|
25
|
+
|
|
26
|
+
This repository contains Python bindings for the txtai API. This is a minimal dependency library for Python designed for use cases where txtai is running through the API. In all other cases, txtai should be installed directly.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
txtai.py can be installed via PyPI
|
|
30
|
+
|
|
31
|
+
pip install txtai.py
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
The examples directory has a series of examples that give an overview of txtai. See the list of examples below.
|
|
35
|
+
|
|
36
|
+
| Example | Description |
|
|
37
|
+
|:----------|:-------------|
|
|
38
|
+
| [Introducing txtai](https://github.com/neuml/txtai.py/blob/master/examples/embeddings.py) | Overview of the functionality provided by txtai |
|
|
39
|
+
| [Extractive QA with txtai](https://github.com/neuml/txtai.py/blob/master/examples/extractor.py) | Extractive question-answering with txtai |
|
|
40
|
+
| [Labeling with zero-shot classification](https://github.com/neuml/txtai.py/blob/master/examples/labels.py) | Labeling with zero-shot classification |
|
|
41
|
+
| [Pipelines and workflows](https://github.com/neuml/txtai.py/blob/master/examples/pipelines.py) | Pipelines and workflows |
|
|
42
|
+
|
|
43
|
+
txtai.py connects to a txtai api instance. See [this link](https://neuml.github.io/txtai/api/) for details on how to start a new api instance.
|
|
44
|
+
|
|
45
|
+
Once an api instance is running, do the following to run the examples.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
git clone https://github.com/neuml/txtai.py
|
|
49
|
+
cd txtai.py/examples
|
|
50
|
+
python embeddings.py
|
|
51
|
+
python extractor.py
|
|
52
|
+
python labels.py
|
|
53
|
+
python pipelines.py
|
|
54
|
+
```
|
txtai.py-6.2.0/setup.cfg
ADDED
txtai.py-6.2.0/setup.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# pylint: disable = C0111
|
|
2
|
+
from setuptools import find_packages, setup
|
|
3
|
+
|
|
4
|
+
with open("README.md", "r", encoding="utf-8") as f:
|
|
5
|
+
# Remove GitHub dark mode images
|
|
6
|
+
DESCRIPTION = "".join([line for line in f if "gh-dark-mode-only" not in line])
|
|
7
|
+
|
|
8
|
+
setup(
|
|
9
|
+
name="txtai.py",
|
|
10
|
+
version="6.2.0",
|
|
11
|
+
author="NeuML",
|
|
12
|
+
description="Python client for txtai",
|
|
13
|
+
long_description=DESCRIPTION,
|
|
14
|
+
long_description_content_type="text/markdown",
|
|
15
|
+
url="https://github.com/neuml/txtai.py",
|
|
16
|
+
project_urls={
|
|
17
|
+
"Documentation": "https://github.com/neuml/txtai.py",
|
|
18
|
+
"Issue Tracker": "https://github.com/neuml/txtai.py/issues",
|
|
19
|
+
"Source Code": "https://github.com/neuml/txtai.py",
|
|
20
|
+
},
|
|
21
|
+
license="Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0",
|
|
22
|
+
packages=find_packages(where="src/python"),
|
|
23
|
+
package_dir={"": "src/python"},
|
|
24
|
+
keywords="search embedding machine-learning nlp",
|
|
25
|
+
python_requires=">=3.8",
|
|
26
|
+
install_requires=["aiohttp>=3.8.1"],
|
|
27
|
+
classifiers=[
|
|
28
|
+
"License :: OSI Approved :: Apache Software License",
|
|
29
|
+
"Operating System :: OS Independent",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
32
|
+
"Topic :: Software Development",
|
|
33
|
+
"Topic :: Text Processing :: Indexing",
|
|
34
|
+
"Topic :: Utilities",
|
|
35
|
+
],
|
|
36
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Client imports
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from .api import API
|
|
7
|
+
from .embeddings import Embeddings
|
|
8
|
+
from .extractor import Extractor
|
|
9
|
+
from .labels import Labels
|
|
10
|
+
from .segmentation import Segmentation
|
|
11
|
+
from .similarity import Similarity
|
|
12
|
+
from .summary import Summary
|
|
13
|
+
from .textractor import Textractor
|
|
14
|
+
from .transcription import Transcription
|
|
15
|
+
from .translation import Translation
|
|
16
|
+
from .workflow import Workflow
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""
|
|
2
|
+
API module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
|
|
7
|
+
from urllib.parse import urlencode
|
|
8
|
+
|
|
9
|
+
import aiohttp
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class API:
|
|
13
|
+
"""
|
|
14
|
+
Base API class.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, url):
|
|
18
|
+
"""
|
|
19
|
+
Creates a new API instance.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
config: cluster configuration
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
# Server URL
|
|
26
|
+
self.url = url
|
|
27
|
+
|
|
28
|
+
def execute(self, method, action, data=None):
|
|
29
|
+
"""
|
|
30
|
+
Executes a HTTP action asynchronously.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
method: get or post
|
|
34
|
+
action: url action to perform
|
|
35
|
+
data: post parameters
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
json results if any
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
close = False
|
|
42
|
+
|
|
43
|
+
# Use existing loop if available, otherwise create one
|
|
44
|
+
try:
|
|
45
|
+
loop = asyncio.get_event_loop()
|
|
46
|
+
except RuntimeError:
|
|
47
|
+
loop = asyncio.new_event_loop()
|
|
48
|
+
close = True
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
return loop.run_until_complete(self.run(method, action, data))
|
|
52
|
+
finally:
|
|
53
|
+
# Close loop if it was created in this method
|
|
54
|
+
if close:
|
|
55
|
+
loop.close()
|
|
56
|
+
|
|
57
|
+
async def run(self, method, action, data):
|
|
58
|
+
"""
|
|
59
|
+
Runs an async action.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
method: get or post
|
|
63
|
+
action: url action to perform
|
|
64
|
+
data: post parameters
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
json results if any
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
async with aiohttp.ClientSession(raise_for_status=True) as session:
|
|
71
|
+
url, task = f"{self.url}/{action}", None
|
|
72
|
+
if method == "post":
|
|
73
|
+
task = asyncio.ensure_future(self.post(session, url, data))
|
|
74
|
+
else:
|
|
75
|
+
task = asyncio.ensure_future(self.get(session, url, data))
|
|
76
|
+
|
|
77
|
+
# Run and wait for task to complete
|
|
78
|
+
return await task
|
|
79
|
+
|
|
80
|
+
async def get(self, session, url, data):
|
|
81
|
+
"""
|
|
82
|
+
Runs an async HTTP GET request.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
session: ClientSession
|
|
86
|
+
url: url
|
|
87
|
+
data: url parameters
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
json results if any
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
# Build URL with parameters
|
|
94
|
+
parameters = urlencode(data) if data else None
|
|
95
|
+
url = f"{url}?{parameters}" if parameters else url
|
|
96
|
+
|
|
97
|
+
async with session.get(url) as resp:
|
|
98
|
+
return await resp.json()
|
|
99
|
+
|
|
100
|
+
async def post(self, session, url, data):
|
|
101
|
+
"""
|
|
102
|
+
Runs an async HTTP POST request.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
session: ClientSession
|
|
106
|
+
url: url
|
|
107
|
+
data: data to POST
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
json results if any
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
async with session.post(url, json=data) as resp:
|
|
114
|
+
return await resp.json()
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""
|
|
2
|
+
API module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Embeddings(API):
|
|
9
|
+
"""
|
|
10
|
+
Embeddings instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def search(self, query, limit=None, weights=None, index=None):
|
|
14
|
+
"""
|
|
15
|
+
Finds documents most similar to the input query. This method will run either an index search
|
|
16
|
+
or an index + database search depending on if a database is available.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
query: input query
|
|
20
|
+
limit: maximum results
|
|
21
|
+
weights: hybrid score weights, if applicable
|
|
22
|
+
index: index name, if applicable
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
list of {id: value, score: value} for index search, list of dict for an index + database search
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
# Build URL
|
|
29
|
+
action = "search"
|
|
30
|
+
data = {"query": query}
|
|
31
|
+
if limit:
|
|
32
|
+
data["limit"] = limit
|
|
33
|
+
if weights:
|
|
34
|
+
data["weights"] = weights
|
|
35
|
+
if index:
|
|
36
|
+
data["index"] = index
|
|
37
|
+
|
|
38
|
+
# Run query
|
|
39
|
+
return self.execute("get", action, data)
|
|
40
|
+
|
|
41
|
+
def batchsearch(self, queries, limit=None, weights=None, index=None):
|
|
42
|
+
"""
|
|
43
|
+
Finds documents most similar to the input queries. This method will run either an index search
|
|
44
|
+
or an index + database search depending on if a database is available.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
queries: input queries
|
|
48
|
+
limit: maximum results
|
|
49
|
+
weights: hybrid score weights, if applicable
|
|
50
|
+
index: index name, if applicable
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
list of {id: value, score: value} per query for index search, list of dict per query for an index + database search
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
# POST parameters
|
|
57
|
+
params = {"queries": queries}
|
|
58
|
+
if limit:
|
|
59
|
+
params["limit"] = limit
|
|
60
|
+
if weights:
|
|
61
|
+
params["weights"] = weights
|
|
62
|
+
if index:
|
|
63
|
+
params["index"] = index
|
|
64
|
+
|
|
65
|
+
# Run query
|
|
66
|
+
return self.execute("post", "batchsearch", params)
|
|
67
|
+
|
|
68
|
+
def add(self, documents):
|
|
69
|
+
"""
|
|
70
|
+
Adds a batch of documents for indexing.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
documents: list of {id: value, text: value}
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
self.execute("post", "add", documents)
|
|
77
|
+
|
|
78
|
+
def index(self):
|
|
79
|
+
"""
|
|
80
|
+
Builds an embeddings index for previously batched documents.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
self.execute("get", "index")
|
|
84
|
+
|
|
85
|
+
def upsert(self):
|
|
86
|
+
"""
|
|
87
|
+
Runs an embeddings upsert operation for previously batched documents.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
self.execute("get", "upsert")
|
|
91
|
+
|
|
92
|
+
def delete(self, ids):
|
|
93
|
+
"""
|
|
94
|
+
Deletes from an embeddings index. Returns list of ids deleted.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
ids: list of ids to delete
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
ids deleted
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
return self.execute("post", "delete", ids)
|
|
104
|
+
|
|
105
|
+
def reindex(self, config, function=None):
|
|
106
|
+
"""
|
|
107
|
+
Recreates this embeddings index using config. This method only works if document content storage is enabled.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
config: new config
|
|
111
|
+
function: optional function to prepare content for indexing
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
self.execute("post", "reindex", {"config": config, "function": function})
|
|
115
|
+
|
|
116
|
+
def count(self):
|
|
117
|
+
"""
|
|
118
|
+
Total number of elements in this embeddings index.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
number of elements in embeddings index
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
return self.execute("get", "count")
|
|
125
|
+
|
|
126
|
+
def similarity(self, query, texts):
|
|
127
|
+
"""
|
|
128
|
+
Computes the similarity between query and list of text. Returns a list of
|
|
129
|
+
{id: value, score: value} sorted by highest score, where id is the index
|
|
130
|
+
in texts.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
query: query text
|
|
134
|
+
texts: list of text
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
list of {id: value, score: value}
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
return self.execute("post", "similarity", {"query": query, "texts": texts})
|
|
141
|
+
|
|
142
|
+
def batchsimilarity(self, queries, texts):
|
|
143
|
+
"""
|
|
144
|
+
Computes the similarity between list of queries and list of text. Returns a list
|
|
145
|
+
of {id: value, score: value} sorted by highest score per query, where id is the
|
|
146
|
+
index in texts.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
queries: queries text
|
|
150
|
+
texts: list of text
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
list of {id: value, score: value} per query
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
return self.execute("post", "batchsimilarity", {"queries": queries, "texts": texts})
|
|
157
|
+
|
|
158
|
+
def transform(self, text):
|
|
159
|
+
"""
|
|
160
|
+
Transforms text into an embeddings array.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
text: input text
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
embeddings array
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
return self.execute("get", "transform", {"text": text})
|
|
170
|
+
|
|
171
|
+
def batchtransform(self, texts):
|
|
172
|
+
"""
|
|
173
|
+
Transforms list of text into embeddings arrays.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
texts: list of text
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
embeddings arrays
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
return self.execute("post", "batchtransform", texts)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Extractor module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Extractor(API):
|
|
9
|
+
"""
|
|
10
|
+
Extractor instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def extract(self, queue, texts=None):
|
|
14
|
+
"""
|
|
15
|
+
Extracts answers to input questions.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
queue: list of {name: value, query: value, question: value, snippet: value}
|
|
19
|
+
texts: optional list of text
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
list of {name: value, answer: value}
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
return self.execute("post", "extract", {"queue": queue, "texts": texts})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Labels module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Labels(API):
|
|
9
|
+
"""
|
|
10
|
+
Labels instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def label(self, text, labels):
|
|
14
|
+
"""
|
|
15
|
+
Applies a zero shot classifier to text using a list of labels. Returns a list of
|
|
16
|
+
{id: value, score: value} sorted by highest score, where id is the index in labels.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
text: input text
|
|
20
|
+
labels: list of labels
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
list of {id: value, score: value} per text element
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
return self.execute("post", "label", {"text": text, "labels": labels})
|
|
27
|
+
|
|
28
|
+
def batchlabel(self, texts, labels):
|
|
29
|
+
"""
|
|
30
|
+
Applies a zero shot classifier to list of text using a list of labels. Returns a list of
|
|
31
|
+
{id: value, score: value} sorted by highest score, where id is the index in labels per
|
|
32
|
+
text element.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
texts: list of text
|
|
36
|
+
labels: list of labels
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
list of {id: value score: value} per text element
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
return self.execute("post", "batchlabel", {"texts": texts, "labels": labels})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Segmentation module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Segmentation(API):
|
|
9
|
+
"""
|
|
10
|
+
Segmentation instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def segment(self, text):
|
|
14
|
+
"""
|
|
15
|
+
Segments text into semantic units.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
text: input text
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
segmented text
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
return self.execute("get", "segment", {"text": text})
|
|
25
|
+
|
|
26
|
+
def batchsegment(self, texts):
|
|
27
|
+
"""
|
|
28
|
+
Segments text into semantic units.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
texts: list of texts to segment
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
list of segmented text
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
return self.execute("post", "batchsegment", {"texts": texts})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Similarity module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Similarity(API):
|
|
9
|
+
"""
|
|
10
|
+
Similarity instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def similarity(self, query, texts):
|
|
14
|
+
"""
|
|
15
|
+
Computes the similarity between query and list of text. Returns a list of
|
|
16
|
+
{id: value, score: value} sorted by highest score, where id is the index
|
|
17
|
+
in texts.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
query: query text
|
|
21
|
+
texts: list of text
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
list of {id: value, score: value}
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
return self.execute("post", "similarity", {"query": query, "texts": texts})
|
|
28
|
+
|
|
29
|
+
def batchsimilarity(self, queries, texts):
|
|
30
|
+
"""
|
|
31
|
+
Computes the similarity between list of queries and list of text. Returns a list
|
|
32
|
+
of {id: value, score: value} sorted by highest score per query, where id is the
|
|
33
|
+
index in texts.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
queries: queries text
|
|
37
|
+
texts: list of text
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
list of {id: value, score: value} per query
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
return self.execute("post", "batchsimilarity", {"queries": queries, "texts": texts})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Summary module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Summary(API):
|
|
9
|
+
"""
|
|
10
|
+
Summary instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def summary(self, text, minlength=None, maxlength=None):
|
|
14
|
+
"""
|
|
15
|
+
Runs a summarization model against a block of text.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
text: text to summarize
|
|
19
|
+
minlength: minimum length for summary
|
|
20
|
+
maxlength: maximum length for summary
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
summary text
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
params = {"text": text}
|
|
27
|
+
if minlength:
|
|
28
|
+
params["minlength"] = minlength
|
|
29
|
+
if maxlength:
|
|
30
|
+
params["maxlength"] = maxlength
|
|
31
|
+
|
|
32
|
+
return self.execute("get", "summary", params)
|
|
33
|
+
|
|
34
|
+
def batchsimilarity(self, texts, minlength=None, maxlength=None):
|
|
35
|
+
"""
|
|
36
|
+
Runs a summarization model against a block of text.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
texts: list of text to summarize
|
|
40
|
+
minlength: minimum length for summary
|
|
41
|
+
maxlength: maximum length for summary
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
list of summary text
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
params = {"texts": texts}
|
|
48
|
+
if minlength:
|
|
49
|
+
params["minlength"] = minlength
|
|
50
|
+
if maxlength:
|
|
51
|
+
params["maxlength"] = maxlength
|
|
52
|
+
|
|
53
|
+
return self.execute("post", "batchsummary", params)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Textractor module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Textractor(API):
|
|
9
|
+
"""
|
|
10
|
+
Textractor instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def textract(self, file):
|
|
14
|
+
"""
|
|
15
|
+
Extracts text from a file at path.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
file: file to extract text
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
extracted text
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
return self.execute("get", "textract", {"file": file})
|
|
25
|
+
|
|
26
|
+
def batchtextract(self, files):
|
|
27
|
+
"""
|
|
28
|
+
Extracts text from a file at path.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
files: list of files to extract text
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
list of extracted text
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
return self.execute("post", "batchtextract", files)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Transcription module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Transcription(API):
|
|
9
|
+
"""
|
|
10
|
+
Transcription instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def transcribe(self, file):
|
|
14
|
+
"""
|
|
15
|
+
Transcribes audio files to text.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
file: file to transcribe
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
transcribed text
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
return self.execute("get", "transcribe", {"file": file})
|
|
25
|
+
|
|
26
|
+
def batchtranscribe(self, files):
|
|
27
|
+
"""
|
|
28
|
+
Transcribes audio files to text.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
files: list of files to transcribe
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
list of transcribed text
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
return self.execute("post", "batchtranscribe", files)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Translation module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Translation(API):
|
|
9
|
+
"""
|
|
10
|
+
Translation instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def translate(self, text, target=None, source=None):
|
|
14
|
+
"""
|
|
15
|
+
Translates text from source language into target language.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
text: text to translate
|
|
19
|
+
target: target language code, defaults to "en"
|
|
20
|
+
source: source language code, detects language if not provided
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
translated text
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
params = {"text": text}
|
|
27
|
+
if target:
|
|
28
|
+
params["target"] = target
|
|
29
|
+
if source:
|
|
30
|
+
params["source"] = source
|
|
31
|
+
|
|
32
|
+
return self.execute("get", "translate", params)
|
|
33
|
+
|
|
34
|
+
def batchtranslate(self, texts, target=None, source=None):
|
|
35
|
+
"""
|
|
36
|
+
Translates text from source language into target language.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
texts: list of text to translate
|
|
40
|
+
target: target language code, defaults to "en"
|
|
41
|
+
source: source language code, detects language if not provided
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
list of translated text
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
params = {"texts": texts}
|
|
48
|
+
if target:
|
|
49
|
+
params["target"] = target
|
|
50
|
+
if source:
|
|
51
|
+
params["source"] = source
|
|
52
|
+
|
|
53
|
+
return self.execute("post", "batchtranslate", params)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Workflow module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .api import API
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Workflow(API):
|
|
9
|
+
"""
|
|
10
|
+
Workflow instance.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def workflow(self, name, elements):
|
|
14
|
+
"""
|
|
15
|
+
Executes a named workflow using elements as input.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
name: workflow name
|
|
19
|
+
elements: list of elements to run through workflow
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
list of processed elements
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
return self.execute("post", "workflow", {"name": name, "elements": elements})
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: txtai.py
|
|
3
|
+
Version: 6.2.0
|
|
4
|
+
Summary: Python client for txtai
|
|
5
|
+
Home-page: https://github.com/neuml/txtai.py
|
|
6
|
+
Author: NeuML
|
|
7
|
+
License: Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
Project-URL: Documentation, https://github.com/neuml/txtai.py
|
|
9
|
+
Project-URL: Issue Tracker, https://github.com/neuml/txtai.py/issues
|
|
10
|
+
Project-URL: Source Code, https://github.com/neuml/txtai.py
|
|
11
|
+
Keywords: search embedding machine-learning nlp
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
18
|
+
Classifier: Topic :: Utilities
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: aiohttp>=3.8.1
|
|
23
|
+
|
|
24
|
+
<p align="center">
|
|
25
|
+
<img src="https://raw.githubusercontent.com/neuml/txtai/master/logo.png"/>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<b>Python client for txtai</b>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<a href="https://github.com/neuml/txtai.py/releases">
|
|
34
|
+
<img src="https://img.shields.io/github/release/neuml/txtai.py.svg?style=flat&color=success" alt="Version"/>
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://github.com/neuml/txtai.py/releases">
|
|
37
|
+
<img src="https://img.shields.io/github/release-date/neuml/txtai.py.svg?style=flat&color=blue" alt="GitHub Release Date"/>
|
|
38
|
+
</a>
|
|
39
|
+
<a href="https://github.com/neuml/txtai.py/issues">
|
|
40
|
+
<img src="https://img.shields.io/github/issues/neuml/txtai.py.svg?style=flat&color=success" alt="GitHub Issues"/>
|
|
41
|
+
</a>
|
|
42
|
+
<a href="https://github.com/neuml/txtai.py">
|
|
43
|
+
<img src="https://img.shields.io/github/last-commit/neuml/txtai.py.svg?style=flat&color=blue" alt="GitHub Last Commit"/>
|
|
44
|
+
</a>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
[txtai](https://github.com/neuml/txtai) is an all-in-one embeddings database for semantic search, LLM orchestration and language model workflows.
|
|
48
|
+
|
|
49
|
+
This repository contains Python bindings for the txtai API. This is a minimal dependency library for Python designed for use cases where txtai is running through the API. In all other cases, txtai should be installed directly.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
txtai.py can be installed via PyPI
|
|
53
|
+
|
|
54
|
+
pip install txtai.py
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
The examples directory has a series of examples that give an overview of txtai. See the list of examples below.
|
|
58
|
+
|
|
59
|
+
| Example | Description |
|
|
60
|
+
|:----------|:-------------|
|
|
61
|
+
| [Introducing txtai](https://github.com/neuml/txtai.py/blob/master/examples/embeddings.py) | Overview of the functionality provided by txtai |
|
|
62
|
+
| [Extractive QA with txtai](https://github.com/neuml/txtai.py/blob/master/examples/extractor.py) | Extractive question-answering with txtai |
|
|
63
|
+
| [Labeling with zero-shot classification](https://github.com/neuml/txtai.py/blob/master/examples/labels.py) | Labeling with zero-shot classification |
|
|
64
|
+
| [Pipelines and workflows](https://github.com/neuml/txtai.py/blob/master/examples/pipelines.py) | Pipelines and workflows |
|
|
65
|
+
|
|
66
|
+
txtai.py connects to a txtai api instance. See [this link](https://neuml.github.io/txtai/api/) for details on how to start a new api instance.
|
|
67
|
+
|
|
68
|
+
Once an api instance is running, do the following to run the examples.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
git clone https://github.com/neuml/txtai.py
|
|
72
|
+
cd txtai.py/examples
|
|
73
|
+
python embeddings.py
|
|
74
|
+
python extractor.py
|
|
75
|
+
python labels.py
|
|
76
|
+
python pipelines.py
|
|
77
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
src/python/txtai/__init__.py
|
|
6
|
+
src/python/txtai.py.egg-info/PKG-INFO
|
|
7
|
+
src/python/txtai.py.egg-info/SOURCES.txt
|
|
8
|
+
src/python/txtai.py.egg-info/dependency_links.txt
|
|
9
|
+
src/python/txtai.py.egg-info/requires.txt
|
|
10
|
+
src/python/txtai.py.egg-info/top_level.txt
|
|
11
|
+
src/python/txtai/client/__init__.py
|
|
12
|
+
src/python/txtai/client/api.py
|
|
13
|
+
src/python/txtai/client/embeddings.py
|
|
14
|
+
src/python/txtai/client/extractor.py
|
|
15
|
+
src/python/txtai/client/labels.py
|
|
16
|
+
src/python/txtai/client/segmentation.py
|
|
17
|
+
src/python/txtai/client/similarity.py
|
|
18
|
+
src/python/txtai/client/summary.py
|
|
19
|
+
src/python/txtai/client/textractor.py
|
|
20
|
+
src/python/txtai/client/transcription.py
|
|
21
|
+
src/python/txtai/client/translation.py
|
|
22
|
+
src/python/txtai/client/workflow.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aiohttp>=3.8.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
txtai
|